mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-12-08 20:55:14 -05:00
Fix prvSelectHighestPriorityTask list iteration
- Use listGET_OWNER_OF_NEXT_ENTRY to iterate through the ready task list instead of iterating from the head of the list. vListInsertEnd appends a node such that, when using listGET_OWNER_OF_NEXT_ENTRY, it is the last node returned, but it isn't inserted at the tail of the list.
This commit is contained in:
parent
4d34700bcc
commit
9d59571c30
1 changed files with 56 additions and 51 deletions
21
tasks.c
21
tasks.c
|
|
@ -1030,21 +1030,22 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
|
|||
|
||||
if( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxCurrentPriority ] ) ) == pdFALSE )
|
||||
{
|
||||
const List_t * const pxReadyList = &( pxReadyTasksLists[ uxCurrentPriority ] );
|
||||
const ListItem_t * pxEndMarker = listGET_END_MARKER( pxReadyList );
|
||||
ListItem_t * pxIterator;
|
||||
List_t * const pxReadyList = &( pxReadyTasksLists[ uxCurrentPriority ] );
|
||||
configLIST_VOLATILE TCB_t * pxFirstTCB;
|
||||
|
||||
/* The ready task list for uxCurrentPriority is not empty, so uxTopReadyPriority
|
||||
* must not be decremented any further. */
|
||||
xDecrementTopPriority = pdFALSE;
|
||||
|
||||
for( pxIterator = listGET_HEAD_ENTRY( pxReadyList ); pxIterator != pxEndMarker; pxIterator = listGET_NEXT( pxIterator ) )
|
||||
if( listCURRENT_LIST_LENGTH( pxReadyList ) )
|
||||
{
|
||||
/* MISRA Ref 11.5.3 [Void pointer assignment] */
|
||||
/* More details at: https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/main/MISRA.md#rule-115 */
|
||||
/* coverity[misra_c_2012_rule_11_5_violation] */
|
||||
TCB_t * pxTCB = ( TCB_t * ) listGET_LIST_ITEM_OWNER( pxIterator );
|
||||
configLIST_VOLATILE TCB_t * pxTCB;
|
||||
|
||||
listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxReadyList );
|
||||
pxTCB = pxFirstTCB;
|
||||
|
||||
do
|
||||
{
|
||||
#if ( configRUN_MULTIPLE_PRIORITIES == 0 )
|
||||
{
|
||||
/* When falling back to the idle priority because only one priority
|
||||
|
|
@ -1054,6 +1055,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
|
|||
{
|
||||
if( ( pxTCB->uxTaskAttributes & taskATTRIBUTE_IS_IDLE ) == 0U )
|
||||
{
|
||||
listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxReadyList );
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
@ -1100,6 +1102,9 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB ) PRIVILEGED_FUNCTION;
|
|||
/* A task has been selected to run on this core. */
|
||||
break;
|
||||
}
|
||||
|
||||
listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxReadyList );
|
||||
} while( pxTCB != pxFirstTCB );
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue