| 4972 | #if ( configUSE_MUTEXES == 1 ) |
| 4973 | |
| 4974 | BaseType_t xTaskPriorityInherit( TaskHandle_t const pxMutexHolder ) |
| 4975 | { |
| 4976 | TCB_t * const pxMutexHolderTCB = pxMutexHolder; |
| 4977 | BaseType_t xReturn = pdFALSE; |
| 4978 | |
| 4979 | /* If the mutex was given back by an interrupt while the queue was |
| 4980 | * locked then the mutex holder might now be NULL. _RB_ Is this still |
| 4981 | * needed as interrupts can no longer use mutexes? */ |
| 4982 | if( pxMutexHolder != NULL ) |
| 4983 | { |
| 4984 | /* If the holder of the mutex has a priority below the priority of |
| 4985 | * the task attempting to obtain the mutex then it will temporarily |
| 4986 | * inherit the priority of the task attempting to obtain the mutex. */ |
| 4987 | if( pxMutexHolderTCB->uxPriority < pxCurrentTCB->uxPriority ) |
| 4988 | { |
| 4989 | /* Adjust the mutex holder state to account for its new |
| 4990 | * priority. Only reset the event list item value if the value is |
| 4991 | * not being used for anything else. */ |
| 4992 | if( ( listGET_LIST_ITEM_VALUE( &( pxMutexHolderTCB->xEventListItem ) ) & taskEVENT_LIST_ITEM_VALUE_IN_USE ) == 0UL ) |
| 4993 | { |
| 4994 | listSET_LIST_ITEM_VALUE( &( pxMutexHolderTCB->xEventListItem ), ( TickType_t ) configMAX_PRIORITIES - ( TickType_t ) pxCurrentTCB->uxPriority ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ |
| 4995 | } |
| 4996 | else |
| 4997 | { |
| 4998 | mtCOVERAGE_TEST_MARKER(); |
| 4999 | } |
| 5000 | |
| 5001 | /* If the task being modified is in the ready state it will need |
| 5002 | * to be moved into a new list. */ |
| 5003 | if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxMutexHolderTCB->uxPriority ] ), &( pxMutexHolderTCB->xStateListItem ) ) != pdFALSE ) |
| 5004 | { |
| 5005 | if( uxListRemove( &( pxMutexHolderTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) |
| 5006 | { |
| 5007 | /* It is known that the task is in its ready list so |
| 5008 | * there is no need to check again and the port level |
| 5009 | * reset macro can be called directly. */ |
| 5010 | portRESET_READY_PRIORITY( pxMutexHolderTCB->uxPriority, uxTopReadyPriority ); |
| 5011 | } |
| 5012 | else |
| 5013 | { |
| 5014 | mtCOVERAGE_TEST_MARKER(); |
| 5015 | } |
| 5016 | |
| 5017 | /* Inherit the priority before being moved into the new list. */ |
| 5018 | pxMutexHolderTCB->uxPriority = pxCurrentTCB->uxPriority; |
| 5019 | prvAddTaskToReadyList( pxMutexHolderTCB ); |
| 5020 | } |
| 5021 | else |
| 5022 | { |
| 5023 | /* Just inherit the priority. */ |
| 5024 | pxMutexHolderTCB->uxPriority = pxCurrentTCB->uxPriority; |
| 5025 | } |
| 5026 | |
| 5027 | traceTASK_PRIORITY_INHERIT( pxMutexHolderTCB, pxCurrentTCB->uxPriority ); |
| 5028 | |
| 5029 | /* Inheritance occurred. */ |
| 5030 | xReturn = pdTRUE; |
| 5031 | } |
no test coverage detected