</>EmbeddedInterview

What is the tick and what is a tickless idle mode?

MediumRTOS & Real-Time Systems

Short answer: The tick is a periodic timer interrupt (commonly SysTick at 1 kHz, i.e. every 1 ms) that the kernel uses to keep time, wake delayed tasks, handle timeouts, and time-slice equal-priority tasks. In tickless idle mode, when only the idle task is ready, the kernel stops the periodic tick, programs a timer to wake the CPU at the next scheduled event (or on any interrupt), enters a low-power mode, and corrects its tick count on wake-up. This saves a lot of power in battery devices.

Choosing the tick rate

Tick Timing resolution Overhead
100 Hz (10 ms) coarse delays very low
1000 Hz (1 ms) typical moderate
10 kHz fine, but... interrupt overhead becomes significant

Delays are only accurate to ±1 tick: vTaskDelay(1) can return after anything between almost 0 and 1 tick, depending on where in the current tick it was called. For precise timing use hardware timers.

Tickless idle details (FreeRTOS configUSE_TICKLESS_IDLE)

  1. The idle task sees that the next task wake-up is N ticks away (and N ≥ configEXPECTED_IDLE_TIME_BEFORE_SLEEP).
  2. vPortSuppressTicksAndSleep() stops SysTick, programs it (or a low-power timer such as LPTIM/RTC that keeps running in stop mode) for N ticks, and executes WFI.
  3. On wake-up (timer expiry or another interrupt), it computes how many ticks really elapsed and advances the tick count with vTaskStepTick().

Power impact: a 1 kHz tick wakes the CPU 1000 times per second; for a device that is mostly idle, removing those wake-ups can cut average current from hundreds of µA to a few µA. Low-power ports use a low-power timer clocked from the 32 kHz crystal so the MCU can enter stop mode.

Zephyr is tickless by default (CONFIG_TICKLESS_KERNEL) and uses a timeout queue programmed into the system timer.