The Tasks and Co-Routine documentation pages provide information to allow judgment as to when co-routine use may and may not be appropriate. Below is a brief summary. Note that an application can be designed using just tasks, just co-routines, or a mixture of both - however tasks and co-routines use different API functions and therefore a queue (or semaphore) cannot be used to pass data from a task to a co-routine or visa versa.
Co-routines are really only intended for use on very small processors that have severe RAM constraints.
![]() |
Simple. |
![]() |
No restrictions on use. |
![]() |
Supports full preemption. |
![]() |
Fully prioritised. |
![]() |
Each task maintains its own stack resulting in higher RAM usage. |
![]() |
Re-entrancy must be carefully considered if using preemption. |
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.
Co-routines use prioritised cooperative scheduling with respect to other co-routines, but can be included in an application that uses preemptive tasks.
The co-routine implementation is provided through a set of macros.
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. |
Any and all data, files, source code, html content and documentation included in the FreeRTOS distribution or available on this site are the exclusive property of Real Time Engineers Ltd..
See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd..