UnStacked C is a whole-program compiler that translates multithreaded source code into event driven source code. It is based off of another project called C-XML-C. A stripped down copy of C-XML-C is included in the UnStacked C installation. C-XML-C is a project based off of CIL.
In traditional multithreading each thread has an individual stack including all state and local variables. This requires stack swapping routines to switch between threads.
In stackless multithreading we compile an entire program's threads to move their states and variables outside of the stack -- enabling all threads to share a single stack.
Lazy Preemption is a method of translating preemptive multithreads into cooperative multithreads. We implement UnStacked C with Lazy Preemption inside of UnStacked C.
Lazy preemption essentially detects loops in threaded code, and adds conditional yields. With a timer to trigger the yields, these threads can now run concurrently on a cooperative scheduler. This avoids many datafaults caused by typical preemption methods.
At compile time Unstacked C generates a complete call graph of all functions in the application. It uses this information to translate thread local variables into nested structs.
These nested structures effectively replaces the individual thread stacks -- and are optimally allocated without the risk of faults.
To generate these changes, the entire application source code is compiled at once. Unstacked C compiles from multithreaded C code into event driven C code.
Sponsored by Thing Done LLC