Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 1: Introduction and Overview


are actually needed, the kernel swaps them back into memory. The concept ofpage faultsis 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.

Kernel Threads


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 reclaimis used to synchronize modified mappings with underlying block devices — for this reason,
it is sometimes referred to simply aswriting 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.Jiffiesare one possible time base. A global variable namedjiffies_64and its
32-bit counterpartjiffiesare 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,jiffiesis incremented with a frequency determined by the central constant
HZof the kernel. This is usually on the range between 1,000 and 100; in other words, the value ofjiffies
is incremented between 1,000 and 100 times per second.

Timing based onjiffiesis relatively coarse-grained because 1,000 Hz is not an excessively large fre-
quency nowadays. Withhigh-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 tickdynamic. 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.
Free download pdf