next up previous
Next: Isomalloc Thread Migration Up: Thread Migration Previous: Thread Migration

Stack Copying Threads

A naive implementation of this approach called ``stack-copying threads'' is simply to pick one address for the stack system-wide. The thread scheduler then copies each thread's stack data into this address before executing the thread, and copies it out again when the thread is suspended. Because there is only one address used by all active thread stacks even on different processors, migrating a thread is simple.

One complicating factor is that modern machines may not always allocate the system stack at the same virtual memory address on each processor. A fixed stack address makes it easier to mount a buffer overflow (``stack smashing'') attack, so some systems change the stack's starting address from run to run as a security measure. On such systems, it is thus impossible to use the system stack for stack copying threads because the stack address is different on each machine.

Stack copying threads suffer from the high cost incurred by stack copying. Because the entire stack must by copied for each thread switch, changing threads is quite slow, especially when the stack contains a large amount of data. Further, because there is only one stack location, there can only be one thread active in each address space, which means a machine with two physical processors can not run two stack-copying theads from the same address space simultaneously.


next up previous
Next: Isomalloc Thread Migration Up: Thread Migration Previous: Thread Migration
Gengbin Zheng 2006-03-18