Module rkos::thread [] [src]

Threading support.

Threading is the only component that uses virtual memory, which supports stack overflow detection. Thread stacks are mapped into the top of virtual memory, pointing to the physical allocation(s) in the system heap as described by the TCB. Below the current thread's stack, VM is unmapped all the way to the top of the system heap. This permits a good degree of safety even without stack probes since the unmapped region is extremely large (on the order of terabytes) unless the machine has a similarly huge amount of physical memory.

Thus, the thread switch operation is essentially as simple as mapping in the new thread's stack and returning into it.