diff --git a/tasks.c b/tasks.c index e2861dd94aa..fb8ef1dbe19 100644 --- a/tasks.c +++ b/tasks.c @@ -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 ); @@ -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 ) @@ -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