FWhy does eTaskConfirmSleepModeStatus not return eNoTasksWaitingTimeout?

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.

This comment has the information you are lookin for -

  • Suspended means that the task has infinite block time.
  • Blocked mean that the task has a finite block time.

You get eNoTasksWaitingTimeout when all the tasks are suspended i.e. the block time is infinite for all the tasks.

Thank you very much! The mistake was that in the tasks marked as “blocked,” I used osDelay(portMaxDelay), and I thought this would put the task into the “suspended” state. It surprises me that it only puts the task into the “blocked” state.

Thank you for reporting back!