The coroutine API is a basic implementation of a coroutine scheduling model, a lightweight non-preemptive multitasking mechanism.
A Cafe coroutine's non-volatile C state (the
PSR registers, etc.) is saved in an
OSCoroutine on a coroutine context switch.
Coroutines are layered on top of COS threads. The OS thread scheduler does not know about coroutines.
The coroutine API is designed to help
simplify the porting of older code that relies on an existing coroutine model. For example, existing Wii console
applications that use the Wii
can be ported quickly by replacing these calls with the Wii U
OSLoadCoroutine functions, respectively.
A cooperating set of coroutines is restricted to a single thread on a single core. Another, distinct set of cooperating coroutines can use a different thread and core. But a coroutine in one of these sets may not switch to a coroutine in the other set.
||Initializes a coroutine.|
||Loads a previously saved coroutine, switching to it.|
||Saves the current coroutine's state.|
||Switches from the current coroutine to a new one, saving the current coroutine's state.|
Demos are available at the following locations.