|
Serene Runtime 1.0.0
C runtime for the Serene programming language
|
One stack per fiber, mapped with a guard page at the low end so an overflow faults deterministically instead of corrupting a neighbour. More...
#include <fiber.h>
Data Fields | |
| void * | start |
| High end, stack pointer initialises to this address. | |
| void * | limit |
| Low end of usable region. | |
| void * | guard |
| The protected page to detect stack overflows. | |
One stack per fiber, mapped with a guard page at the low end so an overflow faults deterministically instead of corrupting a neighbour.
the layout is like:
|... frames ...|... guard page ...| ^ start ^ limit ^ guard
It is a bit unintuitive to see the guard pointing at the end of the the region, but conventionally, the guard is an OS page and since the stack grows downward and allocations normally grow upward, guard is actually the address that OS (POSIX in this example) will return to us as the starting point of the memory region. Or to put it in different terms, we store the stack frames, starting from the end of the allocated memory for the region and move toward the start of the allocated memory.
| void* srn_fiber_stack_t::guard |
| void* srn_fiber_stack_t::start |