+#if ( configUSE_MUTEXES == 1 )\r
+\r
+ void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, UBaseType_t uxHighestPriorityWaitingTask )\r
+ {\r
+ TCB_t * const pxTCB = pxMutexHolder;\r
+ UBaseType_t uxPriorityUsedOnEntry, uxPriorityToUse;\r
+ const UBaseType_t uxOnlyOneMutexHeld = ( UBaseType_t ) 1;\r
+\r
+ if( pxMutexHolder != NULL )\r
+ {\r
+ /* If pxMutexHolder is not NULL then the holder must hold at least\r
+ one mutex. */\r
+ configASSERT( pxTCB->uxMutexesHeld );\r
+\r
+ /* Determine the priority to which the priority of the task that\r
+ holds the mutex should be set. This will be the greater of the\r
+ holding task's base priority and the priority of the highest\r
+ priority task that is waiting to obtain the mutex. */\r
+ if( pxTCB->uxBasePriority < uxHighestPriorityWaitingTask )\r
+ {\r
+ uxPriorityToUse = uxHighestPriorityWaitingTask;\r
+ }\r
+ else\r
+ {\r
+ uxPriorityToUse = pxTCB->uxBasePriority;\r
+ }\r
+\r
+ /* Does the priority need to change? */\r
+ if( pxTCB->uxPriority != uxPriorityToUse )\r
+ {\r
+ /* Only disinherit if no other mutexes are held. This is a\r
+ simplification in the priority inheritance implementation. If\r
+ the task that holds the mutex is also holding other mutexes then\r
+ the other mutexes may have caused the priority inheritance. */\r
+ if( pxTCB->uxMutexesHeld == uxOnlyOneMutexHeld )\r
+ {\r
+ /* If a task has timed out because it already holds the\r
+ mutex it was trying to obtain then it cannot of inherited\r
+ its own priority. */\r
+ configASSERT( pxTCB != pxCurrentTCB );\r
+\r
+ /* Disinherit the priority, remembering the previous\r
+ priority to facilitate determining the subject task's\r
+ state. */\r
+ traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority );\r
+ uxPriorityUsedOnEntry = pxTCB->uxPriority;\r
+ pxTCB->uxPriority = uxPriorityToUse;\r
+\r
+ /* Only reset the event list item value if the value is not\r
+ being used for anything else. */\r
+ if( ( listGET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL )\r
+ {\r
+ listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) uxPriorityToUse ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
+\r
+ /* If the running task is not the task that holds the mutex\r
+ then the task that holds the mutex could be in either the\r
+ Ready, Blocked or Suspended states. Only remove the task\r
+ from its current state list if it is in the Ready state as\r
+ the task's priority is going to change and there is one\r
+ Ready list per priority. */\r
+ if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxPriorityUsedOnEntry ] ), &( pxTCB->xStateListItem ) ) != pdFALSE )\r
+ {\r
+ if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )\r
+ {\r
+ /* It is known that the task is in its ready list so\r
+ there is no need to check again and the port level\r
+ reset macro can be called directly. */\r
+ portRESET_READY_PRIORITY( pxTCB->uxPriority, uxTopReadyPriority );\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
+\r
+ prvAddTaskToReadyList( pxTCB );\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ mtCOVERAGE_TEST_MARKER();\r
+ }\r
+ }\r
+\r
+#endif /* configUSE_MUTEXES */\r
+/*-----------------------------------------------------------*/\r
+\r