Skip to content

Commit 0d04523

Browse files
committed
Update uxTaskGetSystemState to sync with eTaskGetState
* Task in pending ready list is in eReady state no matter what state list the task is in.
1 parent d0a490e commit 0d04523

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

tasks.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,6 +2566,15 @@ char * pcTaskGetName( TaskHandle_t xTaskToQuery ) /*lint !e971 Unqualified char
25662566
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &( pxReadyTasksLists[ uxQueue ] ), eReady );
25672567
} while( uxQueue > ( UBaseType_t ) tskIDLE_PRIORITY ); /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
25682568

2569+
/* Fill in an TaskStatus_t structure with information on each
2570+
* task in the pending ready list. Tasks in pending ready list are
2571+
* in eReady state. */
2572+
taskENTER_CRITICAL();
2573+
{
2574+
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), &xPendingReadyList, eReady );
2575+
}
2576+
taskEXIT_CRITICAL();
2577+
25692578
/* Fill in an TaskStatus_t structure with information on each
25702579
* task in the Blocked state. */
25712580
uxTask += prvListTasksWithinSingleList( &( pxTaskStatusArray[ uxTask ] ), ( List_t * ) pxDelayedTaskList, eBlocked );
@@ -3874,7 +3883,6 @@ static void prvCheckTasksWaitingTermination( void )
38743883
/*-----------------------------------------------------------*/
38753884

38763885
#if ( configUSE_TRACE_FACILITY == 1 )
3877-
38783886
static UBaseType_t prvListTasksWithinSingleList( TaskStatus_t * pxTaskStatusArray,
38793887
List_t * pxList,
38803888
eTaskState eState )
@@ -3894,8 +3902,26 @@ static void prvCheckTasksWaitingTermination( void )
38943902
do
38953903
{
38963904
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. */
3897-
vTaskGetInfo( ( TaskHandle_t ) pxNextTCB, &( pxTaskStatusArray[ uxTask ] ), pdTRUE, eState );
3898-
uxTask++;
3905+
3906+
/* Tasks in pending ready list are in eReady state regardless of
3907+
* what list the task's state list item is currently placed on.
3908+
* Thus, these tasks can be enumerated in this function directly. */
3909+
if( pxList == &xPendingReadyList )
3910+
{
3911+
vTaskGetInfo( ( TaskHandle_t ) pxNextTCB, &( pxTaskStatusArray[ uxTask ] ), pdTRUE, eState );
3912+
uxTask++;
3913+
}
3914+
else
3915+
{
3916+
/* Tasks may be in pending ready list and other state list at
3917+
* the same time. These tasks should be enumuerated in xPendingReadyList
3918+
* only. */
3919+
if( listIS_CONTAINED_WITHIN( &xPendingReadyList, &( pxNextTCB->xEventListItem ) ) == pdFALSE )
3920+
{
3921+
vTaskGetInfo( ( TaskHandle_t ) pxNextTCB, &( pxTaskStatusArray[ uxTask ] ), pdTRUE, eState );
3922+
uxTask++;
3923+
}
3924+
}
38993925
} while( pxNextTCB != pxFirstTCB );
39003926
}
39013927
else

0 commit comments

Comments
 (0)