Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 15: Time Management


High-resolution timers place more requirements on the architecture-specific code of the individual archi-
tectures than classical timers. The generic time framework provides the foundations for high-resolution
timers. Before getting into the details of high-resolution timers, let’s take a look into how high-precision
timekeeping is achieved in the kernel.

The core of the second timer subsystem of the kernel can be found inkernel/time/hrtimer.c.The
generic timekeeping code that forms the basis for high-resolution timers is located in several files in
kernel/time. After providing an overview of the mechanisms used, the new API that comes with high-
resolution timers is introduced, and then their implementation is examined in detail.

15.3.1 Overview


Figure 15-7 provides an overview of the generic time system that provides the foundation of high-
resolution timers.

CPU 0 CPU 1 CPU 2 CPU 3

tick device tick device tick device tick device

local tick

global
tick

local tick local tick local tick

Jiffies

Figure 15-7: Overview of the generic time subsystem.

First, let’s discuss the available components and data structures, the details of which will be covered
in the course of this chapter. Three mechanisms form the foundation of any time-related task in the
kernel:


  1. Clock Sources(defined bystruct clocksource) — Form the backbone of time manage-
    ment. Essentially each clock source provides a monotonically increasing counter with Read
    Only access for the generic kernel parts. The accurateness of different clock sources varies
    depending on the capabilities of the underlying hardware.

  2. Clock event devices(defined bystruct clock_event_device) — Add the possibility of
    equipping clocks with events that occur at a certain time in the future. Note that it is also
    common to refer to such devices asclock event sourcesfor historical reasons.

  3. Tick Devices(definedstruct tick_device) — Extend clock event sources to provide a
    continuous stream of tick events that happen at regular time intervals. The dynamic tick
    mechanism allows for stopping the periodic tick during certain time intervals, though.

Free download pdf