Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Why are co-routines at lowest priority?

Posted by https://www.google.com/accounts on August 5, 2011
This may be a stupid question, but the stupidest question is the one unasked; so here goes.

I've never used a preemptive system on an embedded controller before, and have been studying the FreeRTOS documentation with interest for most of the day.

I've repeatedly seen it claimed that "preemptive multitasking is rarely the best solution for a given problem on embedded controllers". Which sounds reasonable to me; since preemptive multitasking is a general-purpose solution, it understandably requires additional CPU and memory overhead.

I'm quite familiar with writing code structured as co-routines (or state engines, protothreads, etc.) to support multiple "tasks" on systems without true preemptive tasks. I've already written my own co-routine scheduler that handles priorities, mutexes, blocking, etc. And I think that if written properly and specific to the problem at hand, co-routines can perform more efficiently than preemptive tasks.

However, I'm now facing a complex project on a constrained system (PIC24). It will require many simple, time-critical tasks at various priorities which are best implemented as co-routines for best performance. And it will also require two minimum priority tasks, which are way too complex to restructure as co-routines, but would be easily implemented as preemptable tasks.

But in FreeRTOS, co-routines are at a *lower* priority than preemptable tasks, which is the opposite of what I want. While I'm sure I could, with some effort, solve this by integrating another co-routine scheduler into FreeRTOS by setting it up as a high-priority task, I just can't wrap my head around why FreeRTOS would be set up this way.

Why is FreeRTOS' default implementation of a faster tasking solution (co-routines) seemingly crippled by placing it at a lower priority than a slower tasking solution (preemptive tasks)? I'm sure there's something I'm missing, so any insight would be greatly appreciated.

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]

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

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


FreeRTOS and other embedded software careers at AWS.

FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers


STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner