Quality RTOS & Embedded Software

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


Loading

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 {

			traceCREATE_MUTEX_FAILED();
		}
		configASSERT(pxNewQueue);

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 ]    [ 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.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

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.


Careers

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

Renesas

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