Linux must carry on several time-related activities. For instance, the kernel periodically:
Updates the time elapsed since system startup.
Updates the time and date.
Determines, for every CPU, how long the current process has been running, and preempts it if it has exceeded the time allocated to it. The allocation of time slots (also called quanta ) is discussed in Chapter 11.
Updates resource usage statistics.
Checks whether the interval of time associated with each software timer (see the later section Section 6.6) has elapsed.
Linux’s timekeeping architecture is the set of kernel data structures and functions related to the flow of time. Actually, Intel-based multiprocessor machines have a timekeeping architecture that is slightly different from the timekeeping architecture of uniprocessor machines:
In a uniprocessor system, all time-keeping activities are triggered by interrupts raised by the Programmable Interval Timer.
In a multiprocessor system, all general activities (like handling of software timers) are triggered by the interrupts raised by the PIT, while CPU-specific activities (like monitoring the execution time of the currently running process) are triggered by the interrupts raised by the local APIC timers.
Unfortunately, the distinction between the two cases is somewhat blurred. For instance, some early SMP systems based on Intel 80486 processors didn’t have local APICs. Even nowadays, there are SMP motherboards so buggy that local ...