Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 15: Time Management


depending on which timekeeping model is used. In any case, the handler will set the ball rolling for
periodic low-resolution timekeeping by calling the following two functions:

❑ do_timeis responsible for system-wide, global tasks: Update the jiffies value, and handle process
accounting. On a multiprocessor system, one particular CPU is selected to perform both tasks,
and all other CPUs are not concerned with them.
❑ update_process_timesneeds to be performed by every CPU on SMP systems. Besides pro-
cess accounting, it activates and expires all registered classical low-resolution timers and pro-
vides the scheduler with a sense of time. Since these topics merit a discussion of their own (and
are not so much related to the rest of this section), they are inspected in detail in Section 15.8.
Here we are only concerned with timer activation and expiration, which is triggered by calling
run_local_timers. The function, in turn, raises the softIRQTIMER_SOFTIRQ, and the handler
function is responsible to run the low-resolution timers.

IRQ 0

timer_interrupt

do_timer_interrupt_hook

timer_event_interrupt

update_process_times

do_timer

event handler
of the global
clock

IA-32 AMD64

Figure 15-4: Overview of periodic low-resolution timer interrupts on
IA-32 and AMD64 machines.

First, considerdo_time. The function performs as shown in Figure 15-5.

The global variablejiffies_64(an integer variable with 64 bits on all architectures)^4 is incremented by


  1. All that this means is thatjiffies_64specifies the exact number of timer interrupts since the system
    started. Its value is increased with constant regularity when dynamic ticks are disabled. If dynamic ticks
    are active, more than one tick period can have passed since the last update.


(^4) This is achieved on 32-bit processors by combining two 32-bit variables.

Free download pdf