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.
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.
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.
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)
/* 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 );
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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.