Linux Kernel Architecture

(Jacob Rumans) #1

Time Management


All the methods of deferring work to a future point in time discussed in this book so far do not cover
one specific area — thetime-based deferral of tasks. The different variants that have been discussed
do, of course, give some indication of when a deferred task will be executed (e.g., tasklets when
handling softIRQs), but it is not possible to specify an exact time or a time interval after which
a deferred activity will be performed by the kernel. The simplest kind of usage in this respect is
obviously the implementation of time-outs where the kernel on behalf of a userland process waits
a specific period of time for the arrival of an event — for example, 10 seconds for a user to press a
key as a last opportunity to cancel before an important operation is carried out. Other usages are
widespread in user applications.

The kernel itself also uses timers for various tasks, for example, when devices communicate with
associated hardware, often using protocols with chronologically defined sequences. A large number
of timers are used to specify wait timeouts in TCP implementation.

Depending on the job that needs to be performed, timers need to provide different characteristics,
especially with respect to the maximal possible resolution. This chapter discusses the alternatives
provided by the Linux kernel.

15.1 Overview


First of all, an overview of the subsystem that we are about to inspect in detail is presented.

15.1.1 Types of Timers


The timing subsystem of the kernel has grown tremendously during the development of 2.6. For
the initial releases, the timer subsystem consisted solely of what are now known as low-resolution
timers. Essentially, low-resolution timers are centered around a periodic tick which happens at
regular intervals. Events can be scheduled to be activated at one of these intervals. Pressure to
extend this comparatively simple framework came predominantly from two sources:
Free download pdf