diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index 153fa3f03f..f53c67d4b5 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -3614,6 +3614,7 @@ In fact, nothing below this line has/is. { if( pxTCB->uxPriority < pxCurrentTCB[ xPortGetCoreID() ]->uxPriority ) { + taskENTER_CRITICAL(&xTaskQueueMutex); /* Adjust the mutex holder state to account for its new priority. Only reset the event list item value if the value is not being used for anything else. */ @@ -3649,6 +3650,8 @@ In fact, nothing below this line has/is. pxTCB->uxPriority = pxCurrentTCB[ xPortGetCoreID() ]->uxPriority; } + taskEXIT_CRITICAL(&xTaskQueueMutex); + traceTASK_PRIORITY_INHERIT( pxTCB, pxCurrentTCB[ xPortGetCoreID() ]->uxPriority ); } else @@ -3686,6 +3689,7 @@ In fact, nothing below this line has/is. /* Only disinherit if no other mutexes are held. */ if( pxTCB->uxMutexesHeld == ( UBaseType_t ) 0 ) { + taskENTER_CRITICAL(&xTaskQueueMutex); /* A task can only have an inhertied priority if it holds the mutex. If the mutex is held by a task then it cannot be given from an interrupt, and if a mutex is given by the @@ -3720,6 +3724,7 @@ In fact, nothing below this line has/is. switch should occur when the last mutex is returned whether a task is waiting on it or not. */ xReturn = pdTRUE; + taskEXIT_CRITICAL(&xTaskQueueMutex); } else {