Protothread

Protothreads are used to accomplish a non-preempted form of concurrency known as cooperative multitasking and, therefore, do not incur context switch when yielding to another thread.

Within a protothread, yielding is accomplished by utilizing Duff's device within a thread's function and an external variable used in within the switch statement.

A disadvantage is that local variables within the protothread cannot be trusted to have retained their values across a yield to another context.

[1] An advantage is that they are very lightweight and therefore useful on severely memory constrained systems like small microcontrollers where other solutions are impractical or less desirable.

"[2] The protothread concept was developed by Adam Dunkels and Oliver Schmidt,[3] based on prior work by Simon Tatham[4] and Tom Duff.