Download FreeRTOS

Quality RTOS & Embedded Software

FreeRTOS website now available in Simplified Chinese
New FreeRTOS Long Term Support version now available.
FreeRTOS Extended Maintenance Program (EMP) registration now open.
FreeRTOS-Plus-TCP v3.0.0 released:
Featured FreeRTOS IoT Integrations:

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):

  1. 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.


  2. 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.


  3. Macro implementation

    The co-routine implementation is provided through a set of macros.


  4. Restrictions on use

    The reduction in RAM usage comes at the cost of some stringent restrictions in how co-routines can be structured.

Co-Routine Summary

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.


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.