Quality RTOS & Embedded Software

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


FreeRTOS and priority inversion

Posted by Thomas K.-H. Nittel on July 19, 2006

are ressource semaphors with priority inheritance planned to be realized to avoid priority inversion of tasks?
Thanks in advance.



RE: FreeRTOS and priority inversion

Posted by Richard on July 19, 2006
Hi again,

This is a subject that causes a lot of debate!

Including a priority inversion mechanism is straight forward. I think there may be an example knocking about somewhere.

Basically the semaphore requires an extra member that contains the priority of the task that currently holds the semaphore, as follows:

+ TaskA is priority 1, TaskB priority 2.
+ TaskA taskes the semaphore, its priority is stored in the semaphore.
+ TaskB attempts to get the semaphore. It has a higher priority, so the priority of TaskA is raised to that of TaskB.
+ TaskA releases the semaphore, and as it does so has its priority reset back to that stored in the semaphore.

So you may say, if that is all there is to it, why not implement it, which is where people normally start to disagree with me ;-)

IMHO FreeRTOS.org is designed to work with small embedded systems. As such priority inversion should be taken into account at the application design level. In other words, don't design your application so that priority inversion can occur in the first place. Even with the inversion mechanism in place a higher priority task can be delayed by a lower priority task, albeit for less time than if the inversion prevention mechanism was not in place.

If you were designing a large system where resource management across multiple developers was a trickier problem, then a safeguard within the RTOS itself would be more appropriate. As it is I prefer not to introduce the extra RAM and runtime overhead.

This could be introduced as a compile time option. The original intent was to limit the number of compile time options within the code to aid readability, but this seems to be going out the window somewhat anyway.

Flame away!


RE: FreeRTOS and priority inversion

Posted by Jeff Smith on July 19, 2006
I agree that it is helpful to keep source code simpler for the purpose of troubleshooting, special modification, and code maintenance.

Because I make simple and well integrated solutions on small systems, I prefer to specifically design each application so it does not risk priority inversion. In the long run, I think doing it conciously helps streamline my small systems.

[ 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