Quality RTOS & Embedded Software

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


taskYield in cooperative scheduling

Posted by Rocco Iacchetti on August 28, 2008
I'm running freeRTOS in cooperative scheduling to serve an ultra low-power remote sensor.

Now, if an higher priority task decides to suspend itself for a given amount of time, CPU is correctly given to a lower priority task. Suppose now that the amount of time elapses and the lower priority task is still running, how can the higher priority one be woken up?
The timer interrupt routine just increment ticker. In the function called by this interrupt routine every task that has become ready is moved in ready list, but no taskYield is called. It seems to me that the increment ticker function should return if an higher priority task has been woken up, much like xQueueReceiveFromISR do, for example.
Same problem for xQueueSend (not ISR version). If a lower priority task wakes an higher priority one, there is no way to know if a taskYield should be called or not.

On the other way, simply calling taskYield in the ISR routine or after an xQueueSend works, but it is very inefficient. In fact if the calling task is already the higher one, this will do a useless SAVE/RESTORE context.
Why not provide a function call much like the xxxFromISR version?

Thanks to everyone will help me on this!

RE: taskYield in cooperative scheduling

Posted by Dave on August 28, 2008
Using the cooperative scheduler the tick interrupt will unblock the higher priority task when its delay time expires but will not start it running. The cooperative scheduler will only start the higher task running when the lower task either blocks or calls taskYIELD(). This is why its called cooperative, the switch to a higher priority task will not occur without the say so of the lower priority task. If you want the switch to happen automatically as soon as the higher priority task unblocks then you have to use the preemptive scheduler.

Be careful calling taskYield() from an ISR, some ports allow you to do this directly while other require a bit of special syntax to be used.

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

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

Latest News

Version 10.1.0 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