Datasheet
Mauerer runc01.tex V2 - 09/04/2008 4:13pm Page 16
Chapter 1: Introduction and Overview
are actually needed, the kernel swaps them back into memory. The concept of page faults is used to make
this operation transparent to applications. Swapped-out pages are identified by a special entry in the
page table. When a process attempts to access a page of this kind, the CPU initiates a page fault that is
intercepted by the kernel. The kernel then has the opportunity to swap the data on disk into RAM. The
user process then resumes. Because it is unaware of the page fault, swapping in and out of the page is
totally invisible to the process.
Generic kernel
code
Buddy allocator
Small boxes indicate
page frames
Slab allocator
Figure 1-9: Page frame allocation is performed
by the buddy system, while the slab allocator
is responsible for small-sized allocations and
generic kernel caches.
Page reclaim is used to synchronize modified mappings with underlying block devices — for this reason,
it is sometimes referred to simply as writing back data. Once data have been flushed, the page frame
can be used by the kernel for other purposes (as with swapping). After all, the kernel data structures
contain all the information needed to find the corresponding data on the hard disk when they are again
required.
1.3.6 Timing
The kernel must be capable of measuring time and time differences at various points — when scheduling
processes, for example. Jiffies are one possible time base. A global variable named
jiffies_64
and its
32-bit counterpart
jiffies
are incremented periodically at constant time intervals. The various timer
mechanisms of the underlying architectures are used to perform these updates — each computer archi-
tecture provides some means of executing periodic actions, usually in the form of timer interrupts.
Depending on architecture,
jiffies
is incremented with a frequency determined by the central constant
HZ
of the kernel. This is usually on the range between 1,000 and 100; in other words, the value of
jiffies
is incremented between 1,000 and 100 times per second.
Timing based on
jiffies
is relatively coarse-grained because 1,000 Hz is not an excessively large fre-
quency nowadays. With high-resolution timers, the kernel provides additional means that allows for
keeping time in the regime of nanosecond precision and resolution, depending on the capabilities of
the underlying hardware.
It is possible to make the periodic tick dynamic. When there is little to do and no need for frequent periodic
actions, it does not make sense to periodically generate timer interrupts that prevent the processor from
powering down into deep sleep states. This is helpful in systems where power is scarce, for instance,
laptops and embedded systems.
16