Dynamic Ticks

Periodic ticks have provided a notion of time to the Linux kernel for many of years. The approach is simple and effective, but shows one particular deficiency on systems where power consumption does matter: The periodic tick requires that the system is in an active state at a certain frequency. Longer periods of rest are impossible because of this.

Dynamic ticks mend this problem. The periodic tick is only activated when some tasks actually do need to be performed. Otherwise, it is temporarily disabled. Support for this technique can be selected at compile time, and the resulting system is also referred to as a tickless system. However, this name is not entirely accurate because the fundamental frequency HZ at which the periodic tick operates when it is functional still provides a raster for time flow. Since the tick can be activated and deactivated according to the current needs, the term dynamic ticks fits very well.

How can the kernel decide if the system has nothing to do? Recall from Chapter 2 that if no active tasks are on the run queue, the kernel picks a special task — the idle task — to run. At this point, the dynamic tick mechanism enters the game. Whenever the idle task is selected to run, the periodic tick is disabled until the next timer will expire. The tick is re-enabled again after this time span, or when an interrupt occurs. In the meantime, the CPU can enjoy a well-deserved sleep. Note that only classical timers need to be considered for this purpose. High-resolution timers are not bound by the tick frequency, and are also not implemented on top of periodic ticks.

Before discussing the dynamic tick implementation, let us note that one-shot clocks are a prerequisite for them. Since a key feature of dynamic ticks is that the tick mechanism can be stopped and restarted as necessary, purely periodic timers will fundamentally not suit the mechanism.

In the following, periodic ticks mean a tick implementation that does not use dynamic ticks. This must not be confused with clock event devices that work in periodic mode.

Continue reading here: Data Structures

Was this article helpful?

+1 0