Skip to content

Commit

Permalink
Update uxTaskGetSystemState to sync with eTaskGetState
Browse files Browse the repository at this point in the history
* Task in pending ready list is in eReady state no matter what state
  list the task is in.
  • Loading branch information
chinglee-iot committed Jul 10, 2023
1 parent d0a490e commit 0d04523
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -2566,6 +2566,15 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady );
} while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */

/* Fill in an TaskStatus_t structure with information on each
* task in the pending ready list. Tasks in pending ready list are
* in eReady state. */
taskENTER_CRITICAL();
{
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xPendingReadyList, eReady );
}
taskEXIT_CRITICAL();

/* Fill in an TaskStatus_t structure with information on each
* task in the Blocked state. */
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxDelayedTaskList, eBlocked );
Expand Down Expand Up @@ -3874,7 +3883,6 @@ static void prvCheckTasksWaitingTermination( void )
/*-----------------------------------------------------------*/

#if ( configUSE_TRACE_FACILITY == 1 )

static UBaseType_t prvListTasksWithinSingleList( TaskStatus_t * pxTaskStatusArray,
List_t * pxList,
eTaskState eState )
Expand All @@ -3894,8 +3902,26 @@ static void prvCheckTasksWaitingTermination( void )
do
{
listGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList ); /*lint !e9079 void * is used as this macro is used with timers and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
vTaskGetInfo( ( TaskHandle_t ) pxNextTCB, &( pxTaskStatusArray[ uxTask ] ), pdTRUE, eState );
uxTask++;

/* Tasks in pending ready list are in eReady state regardless of
* what list the task's state list item is currently placed on.
* Thus, these tasks can be enumerated in this function directly. */
if( pxList == &xPendingReadyList )
{
vTaskGetInfo( ( TaskHandle_t ) pxNextTCB, &( pxTaskStatusArray[ uxTask ] ), pdTRUE, eState );
uxTask++;
}
else
{
/* Tasks may be in pending ready list and other state list at
* the same time. These tasks should be enumuerated in xPendingReadyList
* only. */
if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxNextTCB->xEventListItem ) ) == pdFALSE )
{
vTaskGetInfo( ( TaskHandle_t ) pxNextTCB, &( pxTaskStatusArray[ uxTask ] ), pdTRUE, eState );
uxTask++;
}
}
} while( pxNextTCB != pxFirstTCB );
}
else
Expand Down

0 comments on commit 0d04523

Please sign in to comment.