@@ -6596,91 +6596,95 @@ static void prvResetNextTaskUnblockTime( void )
65966596
65976597 traceENTER_xTaskPriorityInherit ( pxMutexHolder );
65986598
6599- /* If the mutex is taken by an interrupt, the mutex holder is NULL. Priority
6600- * inheritance is not applied in this scenario. */
6601- if ( pxMutexHolder != NULL )
6599+ taskENTER_CRITICAL ();
66026600 {
6603- /* If the holder of the mutex has a priority below the priority of
6604- * the task attempting to obtain the mutex then it will temporarily
6605- * inherit the priority of the task attempting to obtain the mutex. */
6606- if ( pxMutexHolderTCB -> uxPriority < pxCurrentTCB -> uxPriority )
6601+ /* If the mutex is taken by an interrupt, the mutex holder is NULL. Priority
6602+ * inheritance is not applied in this scenario. */
6603+ if ( pxMutexHolder != NULL )
66076604 {
6608- /* Adjust the mutex holder state to account for its new
6609- * priority. Only reset the event list item value if the value is
6610- * not being used for anything else. */
6611- if ( ( listGET_LIST_ITEM_VALUE ( & ( pxMutexHolderTCB -> xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == ( ( TickType_t ) 0U ) )
6612- {
6613- listSET_LIST_ITEM_VALUE ( & ( pxMutexHolderTCB -> xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB -> uxPriority );
6614- }
6615- else
6605+ /* If the holder of the mutex has a priority below the priority of
6606+ * the task attempting to obtain the mutex then it will temporarily
6607+ * inherit the priority of the task attempting to obtain the mutex. */
6608+ if ( pxMutexHolderTCB -> uxPriority < pxCurrentTCB -> uxPriority )
66166609 {
6617- mtCOVERAGE_TEST_MARKER ();
6618- }
6619-
6620- /* If the task being modified is in the ready state it will need
6621- * to be moved into a new list. */
6622- if ( listIS_CONTAINED_WITHIN ( & ( pxReadyTasksLists [ pxMutexHolderTCB -> uxPriority ] ), & ( pxMutexHolderTCB -> xStateListItem ) ) != pdFALSE )
6623- {
6624- if ( uxListRemove ( & ( pxMutexHolderTCB -> xStateListItem ) ) == ( UBaseType_t ) 0 )
6610+ /* Adjust the mutex holder state to account for its new
6611+ * priority. Only reset the event list item value if the value is
6612+ * not being used for anything else. */
6613+ if ( ( listGET_LIST_ITEM_VALUE ( & ( pxMutexHolderTCB -> xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == ( ( TickType_t ) 0U ) )
66256614 {
6626- /* It is known that the task is in its ready list so
6627- * there is no need to check again and the port level
6628- * reset macro can be called directly. */
6629- portRESET_READY_PRIORITY ( pxMutexHolderTCB -> uxPriority , uxTopReadyPriority );
6615+ listSET_LIST_ITEM_VALUE ( & ( pxMutexHolderTCB -> xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB -> uxPriority );
66306616 }
66316617 else
66326618 {
66336619 mtCOVERAGE_TEST_MARKER ();
66346620 }
66356621
6636- /* Inherit the priority before being moved into the new list. */
6637- pxMutexHolderTCB -> uxPriority = pxCurrentTCB -> uxPriority ;
6638- prvAddTaskToReadyList ( pxMutexHolderTCB );
6639- #if ( configNUMBER_OF_CORES > 1 )
6622+ /* If the task being modified is in the ready state it will need
6623+ * to be moved into a new list. */
6624+ if ( listIS_CONTAINED_WITHIN ( & ( pxReadyTasksLists [ pxMutexHolderTCB -> uxPriority ] ), & ( pxMutexHolderTCB -> xStateListItem ) ) != pdFALSE )
66406625 {
6641- /* The priority of the task is raised. Yield for this task
6642- * if it is not running. */
6643- if ( taskTASK_IS_RUNNING ( pxMutexHolderTCB ) != pdTRUE )
6626+ if ( uxListRemove ( & ( pxMutexHolderTCB -> xStateListItem ) ) == ( UBaseType_t ) 0 )
66446627 {
6645- prvYieldForTask ( pxMutexHolderTCB );
6628+ /* It is known that the task is in its ready list so
6629+ * there is no need to check again and the port level
6630+ * reset macro can be called directly. */
6631+ portRESET_READY_PRIORITY ( pxMutexHolderTCB -> uxPriority , uxTopReadyPriority );
6632+ }
6633+ else
6634+ {
6635+ mtCOVERAGE_TEST_MARKER ();
6636+ }
6637+
6638+ /* Inherit the priority before being moved into the new list. */
6639+ pxMutexHolderTCB -> uxPriority = pxCurrentTCB -> uxPriority ;
6640+ prvAddTaskToReadyList ( pxMutexHolderTCB );
6641+ #if ( configNUMBER_OF_CORES > 1 )
6642+ {
6643+ /* The priority of the task is raised. Yield for this task
6644+ * if it is not running. */
6645+ if ( taskTASK_IS_RUNNING ( pxMutexHolderTCB ) != pdTRUE )
6646+ {
6647+ prvYieldForTask ( pxMutexHolderTCB );
6648+ }
66466649 }
6650+ #endif /* if ( configNUMBER_OF_CORES > 1 ) */
6651+ }
6652+ else
6653+ {
6654+ /* Just inherit the priority. */
6655+ pxMutexHolderTCB -> uxPriority = pxCurrentTCB -> uxPriority ;
66476656 }
6648- #endif /* if ( configNUMBER_OF_CORES > 1 ) */
6649- }
6650- else
6651- {
6652- /* Just inherit the priority. */
6653- pxMutexHolderTCB -> uxPriority = pxCurrentTCB -> uxPriority ;
6654- }
66556657
6656- traceTASK_PRIORITY_INHERIT ( pxMutexHolderTCB , pxCurrentTCB -> uxPriority );
6658+ traceTASK_PRIORITY_INHERIT ( pxMutexHolderTCB , pxCurrentTCB -> uxPriority );
66576659
6658- /* Inheritance occurred. */
6659- xReturn = pdTRUE ;
6660- }
6661- else
6662- {
6663- if ( pxMutexHolderTCB -> uxBasePriority < pxCurrentTCB -> uxPriority )
6664- {
6665- /* The base priority of the mutex holder is lower than the
6666- * priority of the task attempting to take the mutex, but the
6667- * current priority of the mutex holder is not lower than the
6668- * priority of the task attempting to take the mutex.
6669- * Therefore the mutex holder must have already inherited a
6670- * priority, but inheritance would have occurred if that had
6671- * not been the case. */
6660+ /* Inheritance occurred. */
66726661 xReturn = pdTRUE ;
66736662 }
66746663 else
66756664 {
6676- mtCOVERAGE_TEST_MARKER ();
6665+ if ( pxMutexHolderTCB -> uxBasePriority < pxCurrentTCB -> uxPriority )
6666+ {
6667+ /* The base priority of the mutex holder is lower than the
6668+ * priority of the task attempting to take the mutex, but the
6669+ * current priority of the mutex holder is not lower than the
6670+ * priority of the task attempting to take the mutex.
6671+ * Therefore the mutex holder must have already inherited a
6672+ * priority, but inheritance would have occurred if that had
6673+ * not been the case. */
6674+ xReturn = pdTRUE ;
6675+ }
6676+ else
6677+ {
6678+ mtCOVERAGE_TEST_MARKER ();
6679+ }
66776680 }
66786681 }
6682+ else
6683+ {
6684+ mtCOVERAGE_TEST_MARKER ();
6685+ }
66796686 }
6680- else
6681- {
6682- mtCOVERAGE_TEST_MARKER ();
6683- }
6687+ taskEXIT_CRITICAL ();
66846688
66856689 traceRETURN_xTaskPriorityInherit ( xReturn );
66866690
0 commit comments