in tasks.c [1361:1451]
eTaskState eTaskGetState( TaskHandle_t xTask )
{
eTaskState eReturn;
List_t const * pxStateList, * pxDelayedList, * pxOverflowedDelayedList;
const TCB_t * const pxTCB = xTask;
configASSERT( pxTCB );
if( pxTCB == pxCurrentTCB )
{
/* The task calling this function is querying its own state. */
eReturn = eRunning;
}
else
{
taskENTER_CRITICAL();
{
pxStateList = listLIST_ITEM_CONTAINER( &( pxTCB->xStateListItem ) );
pxDelayedList = pxDelayedTaskList;
pxOverflowedDelayedList = pxOverflowDelayedTaskList;
}
taskEXIT_CRITICAL();
if( ( pxStateList == pxDelayedList ) || ( pxStateList == pxOverflowedDelayedList ) )
{
/* The task being queried is referenced from one of the Blocked
* lists. */
eReturn = eBlocked;
}
#if ( INCLUDE_vTaskSuspend == 1 )
else if( pxStateList == &xSuspendedTaskList )
{
/* The task being queried is referenced from the suspended
* list. Is it genuinely suspended or is it blocked
* indefinitely? */
if( listLIST_ITEM_CONTAINER( &( pxTCB->xEventListItem ) ) == NULL )
{
#if ( configUSE_TASK_NOTIFICATIONS == 1 )
{
BaseType_t x;
/* The task does not appear on the event list item of
* and of the RTOS objects, but could still be in the
* blocked state if it is waiting on its notification
* rather than waiting on an object. If not, is
* suspended. */
eReturn = eSuspended;
for( x = 0; x < configTASK_NOTIFICATION_ARRAY_ENTRIES; x++ )
{
if( pxTCB->ucNotifyState[ x ] == taskWAITING_NOTIFICATION )
{
eReturn = eBlocked;
break;
}
}
}
#else /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
{
eReturn = eSuspended;
}
#endif /* if ( configUSE_TASK_NOTIFICATIONS == 1 ) */
}
else
{
eReturn = eBlocked;
}
}
#endif /* if ( INCLUDE_vTaskSuspend == 1 ) */
#if ( INCLUDE_vTaskDelete == 1 )
else if( ( pxStateList == &xTasksWaitingTermination ) || ( pxStateList == NULL ) )
{
/* The task being queried is referenced from the deleted
* tasks list, or it is not referenced from any lists at
* all. */
eReturn = eDeleted;
}
#endif
else /*lint !e525 Negative indentation is intended to make use of pre-processor clearer. */
{
/* If the task is not in any other state, it must be in the
* Ready (including pending ready) state. */
eReturn = eReady;
}
}
return eReturn;
} /*lint !e818 xTask cannot be a pointer to const because it is a typedef. */