Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 15: Time Management


Periodic events do not comply with a free running counter very well, thus another abstraction is required.
Clock eventsare the foundation of periodic events. Clockevents can, however, be more powerful. Some
time devices can provide events at arbitrary, irregular points in time. In contrast to periodic event devices,
they are calledone-shotdevices.

The high-resolution timer mechanism is based on clock events, whereas the low-resolution timer mecha-
nism utilizes periodic events that can either come directly from a low-resolution clock or from the high-
resolution subsystem. Two important tasks for which low-resolution timers assume responsibility are


  1. Handle the globaljiffiescounter. The value is incremented periodically (or at least itlooks
    periodical to most parts of the kernel) and represents a particularly simple form of time
    reference.^1

  2. Perform per-process accounting. This also includes handling classical low-resolution timers,
    which can be associated with any process.


15.1.2 Configuration Options


Not only are there two distinct (butnevertheless related) timing subsystems in the kernel, but the situ-
ation is additionally complicated by the dynamic ticks feature. Traditionally, the periodic tick is active
during the entire lifetime of the kernel. This can be wasteful in systems where power is scarce, with lap-
tops and portable machines prime examples. If a periodic event is active, the system will never be able to
go into power-saving modes for long intervals of time. The kernel thus allows to configuredynamic ticks,^2
which do not require a periodic signal. Since this complicates timer handling, assume for now that this
feature is not enabled.

Four different timekeeping scenarios can be realized by the kernel. While the number may not sound too
large, understanding the time-related code is not exactly simplified when many tasks can be implemented
in four different ways depending on the chosen configuration. Figure 15-3 summarizes the possible
choices.

High-res
Dynamic ticks

High-res
Periodic ticks

Low-res
Dynamic ticks

Low-res
Periodic ticks

Figure 15-3: Possible timekeeping
configurations that arise because of
high- and low-resolution timers and
dynamic/periodic ticks.

Computing all four possible combinations from two sets with two elements is certainly not complicated.
Nevertheless, it is important to realize that all combinations of low/high res and dynamic/periodic ticks
are valid and need to be accounted for by the kernel.

(^1) Updating the jiffies value is not easy to categorize between low-and high-resolution frameworksbecause it can be performed by
both, depending on the kernel configuration. The fine details of jiffie updating are discussed in the course of this chapter.
(^2) It is also customary to refer to a system with this configuration option enabled as aticklesssystem.

Free download pdf