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


Priority ceiling protocol in freertos

Posted by yash98 on March 21, 2014

Hello, I am porting freeRTOS in tiva c Series TM4C123GXl. As freertos support priority inheritance protocol, I want to implement priority ceiling protocol in freeRTOS. So I need a idea on how to implement this protocol or code related to it.

Priority ceiling protocol in freertos

Posted by davedoors on March 21, 2014

The task control block already has two priority members uxPriority and uxBasePriority that you can reuse for the priority ceiling implementation. You would have to update the queue structure used by mutexes (defined in queue.c) to include a value for the ceiling priority. The ceiling protocol should be simpler to implement than the existing inheritance protocol.

Priority ceiling protocol in freertos

Posted by yash98 on March 28, 2014

Hello Dave, i am having difficulty in changing the current functionality of freeRTOS in queue.c file to implement ceiling protocol. I am implementing ceiling protocol with priority inheritance. i need to implement a ceiling protocol with following allocation rule : If R (mutex) is free : 1) If priority of Task J is > ceilings priority of all other resources currently acquired by other jobs then allocate R to J. 2)if J is the job holding the resource(s) whose priority ceiling = P(t), allocate R to J 3) otherwise :request denied and blocked J.

Also, if a lower priority task is holding mutex and a higher priority request the mutex then it is blocked if its priority is less than ceilings priority of all other resources currently acquired by other jobs then lower priority inherits the priority of requested task(priority inheritance).

As I am new to this so can you help me out with some details explanation will be very helpfull.

Priority ceiling protocol in freertos

Posted by yash98 on March 29, 2014

I have encountered problem in creating semaphore where my ceiling function is not getting set in queue structure. Following is the Step i have performed in defing ceiling function.

1 ) I have define a macro in semhr.h for creating mutex as

define xSemaphoreCeiling( xCeiling ) xCeilingCreateMutex( (xCeiling) )

2 )Then I have define a ceiling in the queue structure as

unsigned portBASE_TYPE xCeiling; /< define the ceiling of the mutex>/

3 ) I have created the function as

xQueueHandle xCeilingCreateMutex(unsigned portBASE_TYPE xMutexCeiling) { xQUEUE *pxNewQueue;

/* allocate the new queue to Mutex */
pxNewQueue = (xQUEUE *) pvPortMalloc(sizeof(xQUEUE));
if(pxNewQueue != NULL) 

	/*Assign ceiling to the Mutex*/
		pxNewQueue->xCeiling = xMutexCeiling; 
		pxNewQueue->pxMutexHolder = NULL;
		pxNewQueue->pcWriteTo = NULL;
		pxNewQueue->pcReadFrom = NULL;

		/* Each mutex has a length of 1 (like a binary semaphore) and
		an item size of 0 as nothing is actually copied into or out
		of the mutex. */
		pxNewQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U;
		pxNewQueue->uxLength = ( unsigned portBASE_TYPE ) 1U;
		pxNewQueue->uxItemSize = ( unsigned portBASE_TYPE ) 0U;
		pxNewQueue->xRxLock = queueUNLOCKED;
		pxNewQueue->xTxLock = queueUNLOCKED;

	  /* Ensure the event queues start with the correct state. */
		vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );
		vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );

		traceCREATE_MUTEX( pxNewQueue );

		}else {


return pxNewQueue; }

But the pxNewQueue->xCeiling = xMutexCeiling is not called at run time while creating a semaphore . when I try to debug to it, it goes directly to next line
" pxNewQueue->pxMutexHolder = NULL " .

I have also included the above function in queue.h file. Please help me out where I am doing mistake.

[ 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