Tickless idle mode and vTaskSuspend dependency

I am in the process of enabling RTOS tickless idle mode in my project and i found that INCLUDE_vTaskSuspend is mandatory for tickless idle mode. In all my projects i have kept INCLUDE_vTaskSuspend as 0.

As per my understanding, by including INCLUDE_vTaskSuspend causes a new state list is used where suspended tasks listed. A task is suspended if it doesn’t have a timeout or timeout is portMAX_DELAY. If this list was not included then tasks will be placed in delayed or blocked list. so this list is not mandatory ( i also acknowledge the fact that a task can get unblocked when current time exceeds current time plus portMAX_DELAY and this can be addressed by checking return values).

I tried disabling the sanity check pasted below in FreeRTOS.h:

#if( configUSE_TICKLESS_IDLE != 0 )
#if( INCLUDE_vTaskSuspend != 1 )
#error INCLUDE_vTaskSuspend must be set to 1 if configUSE_TICKLESS_IDLE is not set to 0
#endif /* INCLUDE_vTaskSuspend /
#endif /
configUSE_TICKLESS_IDLE */

while compiling its showing error in eTaskConfirmSleepModeStatus() API.
eTaskConfirmSleepModeStatus() checks for suspended list.

  	/* 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;
  	}
  1. Is there any reason not to keep the above lines of code under (INCLUDE_vTaskSuspend == 1) check.
  2. Is it ok to enable tickless idle with INCLUDE_vTaskSuspend as 0.

Regards,
Pramith

Hi Pramith,

With your proposed changes, yes you could safely enable tickless idle without including vTaskSuspend. In fact it seems this is a good change to make.

1 Like

Just from looking at the code it seems the check on whether INCLUDE_vTaskSuspend is 1 or not is in the wrong place, and should only be used to know whether to check the xSuspendedTaskList list or not - as per both prior comments in this thread. It would be appreciated if you created a pull request to make that change. Thanks for taking the time to report.

1 Like

Thanks Richard and Jeff.

Tickless idle mode is working perfectly fine with the changes.
I have created a pull request #422 with these changes.
Glad to make my first contribution to FreeRTOS Kernel.

Thank you for your PR. It has been merged.