Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 15: Time Management


apic_timer_interrupt. The result is that the clock event device cannot distinguish between IPIs and
real interrupts, so the effect is the same as if the device were still functional.

Determine affected CPUs

Current CPU in broadcast mask?

Remove CPU from mask

Call event_handler for current CPU

More CPUs in broadcast mask? Call broadcast method

tick_do_periodic_broadcast

tick_do_broadcast

Figure 15-22: Code flow diagram fortick_do_periodic_broadcast.

Inter-processor interrupts are slow, and thus the required accuracy and resolution for high-resolution
timers will not be available. The kernel therefore always switches to low-resolution mode if broadcasting
is required.

15.7 Implementing Timer-Related System


Calls


The kernel provides several system calls that involve timers; the most important ones are considered in
the following:

15.7.1 Time Bases


When timers are used, there are three options to distinguish how elapsed time is counted or in which time
base^22 the timer resides. The kernel features the following variants that draw attention to themselves by
various signals when a time-out occurs:

❑ ITIMER_REALmeasures the actual elapsed time betweenactivation of the timer and time-out
in order to trigger the signal. In this case, the timer continues to tick regardless of whether the
system is in kernel mode or user mode or whether the application using the timer is currently
running or not. A signal of theSIGALRMtype is sent when the timer times out.
❑ ITIMER_VIRTUALruns only during the time spent by the owner process of the timer in user mode.
In this case, time spent in kernel mode (or when the processor is busy with another application)
is ignored. Time-out is indicated by theSIGVTALRMsignal.
❑ ITIMER_PROFcalculates the time spent by the process both in user and kernel mode — time
continues to elapse when a system call is executed on behalf of the task. Other processes of the
system are ignored. The signal sent at time-out isSIGPROF.

(^22) Often also referred to astime domain.

Free download pdf