@@ -6643,91 +6643,95 @@ static void prvResetNextTaskUnblockTime( void )
6643
6643
6644
6644
traceENTER_xTaskPriorityInherit ( pxMutexHolder );
6645
6645
6646
- /* If the mutex is taken by an interrupt, the mutex holder is NULL. Priority
6647
- * inheritance is not applied in this scenario. */
6648
- if ( pxMutexHolder != NULL )
6646
+ taskENTER_CRITICAL ();
6649
6647
{
6650
- /* If the holder of the mutex has a priority below the priority of
6651
- * the task attempting to obtain the mutex then it will temporarily
6652
- * inherit the priority of the task attempting to obtain the mutex. */
6653
- if ( pxMutexHolderTCB -> uxPriority < pxCurrentTCB -> uxPriority )
6648
+ /* If the mutex is taken by an interrupt, the mutex holder is NULL. Priority
6649
+ * inheritance is not applied in this scenario. */
6650
+ if ( pxMutexHolder != NULL )
6654
6651
{
6655
- /* Adjust the mutex holder state to account for its new
6656
- * priority. Only reset the event list item value if the value is
6657
- * not being used for anything else. */
6658
- if ( ( listGET_LIST_ITEM_VALUE ( & ( pxMutexHolderTCB -> xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == ( ( TickType_t ) 0U ) )
6659
- {
6660
- listSET_LIST_ITEM_VALUE ( & ( pxMutexHolderTCB -> xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB -> uxPriority );
6661
- }
6662
- else
6652
+ /* If the holder of the mutex has a priority below the priority of
6653
+ * the task attempting to obtain the mutex then it will temporarily
6654
+ * inherit the priority of the task attempting to obtain the mutex. */
6655
+ if ( pxMutexHolderTCB -> uxPriority < pxCurrentTCB -> uxPriority )
6663
6656
{
6664
- mtCOVERAGE_TEST_MARKER ();
6665
- }
6666
-
6667
- /* If the task being modified is in the ready state it will need
6668
- * to be moved into a new list. */
6669
- if ( listIS_CONTAINED_WITHIN ( & ( pxReadyTasksLists [ pxMutexHolderTCB -> uxPriority ] ), & ( pxMutexHolderTCB -> xStateListItem ) ) != pdFALSE )
6670
- {
6671
- if ( uxListRemove ( & ( pxMutexHolderTCB -> xStateListItem ) ) == ( UBaseType_t ) 0 )
6657
+ /* Adjust the mutex holder state to account for its new
6658
+ * priority. Only reset the event list item value if the value is
6659
+ * not being used for anything else. */
6660
+ if ( ( listGET_LIST_ITEM_VALUE ( & ( pxMutexHolderTCB -> xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == ( ( TickType_t ) 0U ) )
6672
6661
{
6673
- /* It is known that the task is in its ready list so
6674
- * there is no need to check again and the port level
6675
- * reset macro can be called directly. */
6676
- portRESET_READY_PRIORITY ( pxMutexHolderTCB -> uxPriority , uxTopReadyPriority );
6662
+ listSET_LIST_ITEM_VALUE ( & ( pxMutexHolderTCB -> xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB -> uxPriority );
6677
6663
}
6678
6664
else
6679
6665
{
6680
6666
mtCOVERAGE_TEST_MARKER ();
6681
6667
}
6682
6668
6683
- /* Inherit the priority before being moved into the new list. */
6684
- pxMutexHolderTCB -> uxPriority = pxCurrentTCB -> uxPriority ;
6685
- prvAddTaskToReadyList ( pxMutexHolderTCB );
6686
- #if ( configNUMBER_OF_CORES > 1 )
6669
+ /* If the task being modified is in the ready state it will need
6670
+ * to be moved into a new list. */
6671
+ if ( listIS_CONTAINED_WITHIN ( & ( pxReadyTasksLists [ pxMutexHolderTCB -> uxPriority ] ), & ( pxMutexHolderTCB -> xStateListItem ) ) != pdFALSE )
6687
6672
{
6688
- /* The priority of the task is raised. Yield for this task
6689
- * if it is not running. */
6690
- if ( taskTASK_IS_RUNNING ( pxMutexHolderTCB ) != pdTRUE )
6673
+ if ( uxListRemove ( & ( pxMutexHolderTCB -> xStateListItem ) ) == ( UBaseType_t ) 0 )
6691
6674
{
6692
- prvYieldForTask ( pxMutexHolderTCB );
6675
+ /* It is known that the task is in its ready list so
6676
+ * there is no need to check again and the port level
6677
+ * reset macro can be called directly. */
6678
+ portRESET_READY_PRIORITY ( pxMutexHolderTCB -> uxPriority , uxTopReadyPriority );
6679
+ }
6680
+ else
6681
+ {
6682
+ mtCOVERAGE_TEST_MARKER ();
6683
+ }
6684
+
6685
+ /* Inherit the priority before being moved into the new list. */
6686
+ pxMutexHolderTCB -> uxPriority = pxCurrentTCB -> uxPriority ;
6687
+ prvAddTaskToReadyList ( pxMutexHolderTCB );
6688
+ #if ( configNUMBER_OF_CORES > 1 )
6689
+ {
6690
+ /* The priority of the task is raised. Yield for this task
6691
+ * if it is not running. */
6692
+ if ( taskTASK_IS_RUNNING ( pxMutexHolderTCB ) != pdTRUE )
6693
+ {
6694
+ prvYieldForTask ( pxMutexHolderTCB );
6695
+ }
6693
6696
}
6697
+ #endif /* if ( configNUMBER_OF_CORES > 1 ) */
6698
+ }
6699
+ else
6700
+ {
6701
+ /* Just inherit the priority. */
6702
+ pxMutexHolderTCB -> uxPriority = pxCurrentTCB -> uxPriority ;
6694
6703
}
6695
- #endif /* if ( configNUMBER_OF_CORES > 1 ) */
6696
- }
6697
- else
6698
- {
6699
- /* Just inherit the priority. */
6700
- pxMutexHolderTCB -> uxPriority = pxCurrentTCB -> uxPriority ;
6701
- }
6702
6704
6703
- traceTASK_PRIORITY_INHERIT ( pxMutexHolderTCB , pxCurrentTCB -> uxPriority );
6705
+ traceTASK_PRIORITY_INHERIT ( pxMutexHolderTCB , pxCurrentTCB -> uxPriority );
6704
6706
6705
- /* Inheritance occurred. */
6706
- xReturn = pdTRUE ;
6707
- }
6708
- else
6709
- {
6710
- if ( pxMutexHolderTCB -> uxBasePriority < pxCurrentTCB -> uxPriority )
6711
- {
6712
- /* The base priority of the mutex holder is lower than the
6713
- * priority of the task attempting to take the mutex, but the
6714
- * current priority of the mutex holder is not lower than the
6715
- * priority of the task attempting to take the mutex.
6716
- * Therefore the mutex holder must have already inherited a
6717
- * priority, but inheritance would have occurred if that had
6718
- * not been the case. */
6707
+ /* Inheritance occurred. */
6719
6708
xReturn = pdTRUE ;
6720
6709
}
6721
6710
else
6722
6711
{
6723
- mtCOVERAGE_TEST_MARKER ();
6712
+ if ( pxMutexHolderTCB -> uxBasePriority < pxCurrentTCB -> uxPriority )
6713
+ {
6714
+ /* The base priority of the mutex holder is lower than the
6715
+ * priority of the task attempting to take the mutex, but the
6716
+ * current priority of the mutex holder is not lower than the
6717
+ * priority of the task attempting to take the mutex.
6718
+ * Therefore the mutex holder must have already inherited a
6719
+ * priority, but inheritance would have occurred if that had
6720
+ * not been the case. */
6721
+ xReturn = pdTRUE ;
6722
+ }
6723
+ else
6724
+ {
6725
+ mtCOVERAGE_TEST_MARKER ();
6726
+ }
6724
6727
}
6725
6728
}
6729
+ else
6730
+ {
6731
+ mtCOVERAGE_TEST_MARKER ();
6732
+ }
6726
6733
}
6727
- else
6728
- {
6729
- mtCOVERAGE_TEST_MARKER ();
6730
- }
6734
+ taskEXIT_CRITICAL ();
6731
6735
6732
6736
traceRETURN_xTaskPriorityInherit ( xReturn );
6733
6737
0 commit comments