I use FreeRTOS with tiskless mode enabled.
I’m having trouble understanding what’s happening in the code:
I call this function:
eSleepModeStatus eTaskConfirmSleepModeStatus( void )
{
/* The idle task exists in addition to the application tasks. */
const UBaseType_t uxNonApplicationTasks = 1;
eSleepModeStatus eReturn = eStandardSleep;
/* This function must be called from a critical section. */
if( listCURRENT_LIST_LENGTH( &xPendingReadyList ) != 0 )
{
/* A task was made ready while the scheduler was suspended. */
eReturn = eAbortSleep;
}
else if( xYieldPending != pdFALSE )
{
/* A yield was pended while the scheduler was suspended. */
eReturn = eAbortSleep;
}
else
{
/* If all the tasks are in the suspended list (which might mean they
have an infinite block time rather than actually being suspended)
then it is safe to turn all clocks off and just wait for external
interrupts. */
if( listCURRENT_LIST_LENGTH( &xSuspendedTaskList ) == ( uxCurrentNumberOfTasks - uxNonApplicationTasks ) )
{
eReturn = eNoTasksWaitingTimeout;
}
else
{
mtCOVERAGE_TEST_MARKER();
}
}
return eReturn;
}
xPendingReadyList is zero—meaning there are no pending ready tasks, and xYieldPending is also false. At the same time, xSuspendedTaskList has a length of 9, but uxCurrentNumberOfTasks is 14. So, where are the remaining 5 tasks (14 - 9) that are not suspended?
I’m trying to understand why this function never returns eNoTasksWaitingTimeout, even though, according to the debug output, it seems that all tasks except the Idle task are in the suspended or blocked state.
Could you help clarify this?
Thank you very much.