|Hint: Use the tree menu to navigate groups of related pages|
Characteristics of a ‘Co-routine’
Note: Co-routines were implemented for use on very small devices, but are very rarely used in the field these days. For that reason, while there are no plans to remove co-routines from the code, there are also no plans to develop them further.
Co-routines are conceptually similar to tasks but have the following fundamental differences (elaborated further on the co-routine documentation page):
- Stack usage
All the co-routines within an application share a single stack. This greatly reduces the amount of RAM required compared to a similar application written using tasks.
- Scheduling and priorities
Co-routines use prioritised cooperative scheduling with respect to other co-routines, but can be included in an application that uses preemptive tasks.
- Macro implementation
The co-routine implementation is provided through a set of macros.
- Restrictions on use
The reduction in RAM usage comes at the cost of some stringent restrictions in how co-routines can be structured.
|Sharing a stack between co-routines results in much lower RAM usage.|
|Cooperative operation makes re-entrancy less of an issue.|
|Very portable across architectures.|
|Fully prioritised relative to other co-routines, but can always be preempted by tasks if the two are mixed.|
|Lack of stack requires special consideration.|
|Restrictions on where API calls can be made.|
|Co-operative operation only amongst co-routines themselves.|