Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

xTaskPriorityDisinherit when other mutexes are held

Posted by eklundn on December 8, 2016

Hi. In the function xTaskPriorityDisinherit there is the following check: ~~~ /* Only disinherit if no other mutexes are held. */ if( pxTCB->uxMutexesHeld == ( UBaseType_t ) 0 ) ~~~ Why does the task not disinherit priority when other mutexes are held? The other mutexes might have a lower priority than the current one, but still higher than uxBasePriority.

Best regards.


xTaskPriorityDisinherit when other mutexes are held

Posted by rtel on December 8, 2016

This is a simplification in the priority inheritance implementation done in the interest of simplicity. A full priority inheritance implementation is complex due to the number of scenarios (there are many combinations of the order in which tasks of various priority can take and release semaphores) and thus results in a lot of additional code and data space requirements for scenarios that almost never occur - hence we opted to implement this simplification.


xTaskPriorityDisinherit when other mutexes are held

Posted by eklundn on December 12, 2016

Thanks for the reply. Is there any write up on the alternative, full priority inheritance implementation? And the different situations that are handled or unhandled?

Because at first sight (actually quite many read through) of the code, it seems possible add full support in very few lines of code. First remove the line in my first post, then add lines that set pxTCB->uxPriority to the highest priority of any task that is blocked by other held mutexes, or to pxTCB->uxBasePriority if no tasks of higher priority is blocked.

Would there be any implications of this proposal? Best regards.


xTaskPriorityDisinherit when other mutexes are held

Posted by davedoors on December 12, 2016

add lines that set pxTCB->uxPriority to the highest priority of any task that is blocked by other held mutexes

There is no way to get that information.


xTaskPriorityDisinherit when other mutexes are held

Posted by eklundn on December 14, 2016

There is no way to get that information.

Well, it could be done by changing uxMutexesHeld to a (linked) list of held mutexes. Then for each mutex in uxMutexesHeld in xTaskPriorityDisinherit do something like:

~~~ xTCB *pxWaitingTCB = listGETOWNEROFHEADENTRY(mutex->xTasksWaitingToReceive); if( NULL != pxWaitingTCB && pxWaitingTCB->uxPriority > uxDisinheritPriority) { uxDisinheritPrioriy = pxWaitingTCB->uxPriority; } ~~~

Finaly setting pxTCB->uxPriority = uxDisinheritPriority;

It is not much code and it will not generate significant performance impact since the list of mutexes held will probably be quite short.


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




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM 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.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists