next up previous contents
Next: Executing Programs Up: Processes Previous: Shared Memory

Times and Timers

The kernel keeps track of a processes creation time as well as the CPU time that it consumes during its lifetime. Each clock tick, the kernel updates the amount of time in jiffies  that the current process has spent in system and in user mode.

In addition to these accounting timers, Linux supports process specific interval timers.

A process can use these timers to send itself various signals each time that they expire. Three sorts of interval timers are supported:

the timer ticks in real time, and when the timer has expired, the process is sent a SIGALRM signal.
This timer only ticks when the process is running and when it expires it sends a SIGVTALRM signal.
This timer ticks both when the process is running and when the system is executing on behalf of the process itself. SIGPROF is signalled when it expires.

One or all of the interval timers may be running and Linux keeps all of the neccessary information in the processes task_struct  data structure. System calls can be made to set up these interval timers and to start them, stop them and read their current values. The virtual and profile timers are handled the same way.

Every clock tick the current processes interval timers are decremented and, if they have expired, the appropriate signal is sent.

Real time interval timers are a little different and for these Linux uses the timer mechanism described in Chapter gif. Each process has its own timer_list  data structure and, when the real interval timer is running, this is queued on the system timer list. When the timer expires the timer bottom half handler removes it from the queue and calls the interval timer handler.

This generates the SIGALRM signal and restarts the interval timer, adding it back into the system timer queue.

next up previous contents
Next: Executing Programs Up: Processes Previous: Shared Memory

David A. Rusling