1TIME(7) Linux Programmer's Manual TIME(7)
2
3
4
6 time - overview of time and timers
7
9 Real time and process time
10 Real time is defined as time measured from some fixed point, either
11 from a standard point in the past (see the description of the Epoch and
12 calendar time below), or from some point (e.g., the start) in the life
13 of a process (elapsed time).
14
15 Process time is defined as the amount of CPU time used by a process.
16 This is sometimes divided into user and system components. User CPU
17 time is the time spent executing code in user mode. System CPU time is
18 the time spent by the kernel executing in system mode on behalf of the
19 process (e.g., executing system calls). The time(1) command can be
20 used to determine the amount of CPU time consumed during the execution
21 of a program. A program can determine the amount of CPU time it has
22 consumed using times(2), getrusage(2), or clock(3).
23
24 The hardware clock
25 Most computers have a (battery-powered) hardware clock which the kernel
26 reads at boot time in order to initialize the software clock. For fur‐
27 ther details, see rtc(4) and hwclock(8).
28
29 The software clock, HZ, and jiffies
30 The accuracy of various system calls that set timeouts, (e.g.,
31 select(2), sigtimedwait(2)) and measure CPU time (e.g., getrusage(2))
32 is limited by the resolution of the software clock, a clock maintained
33 by the kernel which measures time in jiffies. The size of a jiffy is
34 determined by the value of the kernel constant HZ.
35
36 The value of HZ varies across kernel versions and hardware platforms.
37 On i386 the situation is as follows: on kernels up to and including
38 2.4.x, HZ was 100, giving a jiffy value of 0.01 seconds; starting with
39 2.6.0, HZ was raised to 1000, giving a jiffy of 0.001 seconds. Since
40 kernel 2.6.13, the HZ value is a kernel configuration parameter and can
41 be 100, 250 (the default) or 1000, yielding a jiffies value of, respec‐
42 tively, 0.01, 0.004, or 0.001 seconds. Since kernel 2.6.20, a further
43 frequency is available: 300, a number that divides evenly for the com‐
44 mon video frame rates (PAL, 25 HZ; NTSC, 30 HZ).
45
46 The times(2) system call is a special case. It reports times with a
47 granularity defined by the kernel constant USER_HZ. User-space appli‐
48 cations can determine the value of this constant using
49 sysconf(_SC_CLK_TCK).
50
51 High-resolution timers
52 Before Linux 2.6.21, the accuracy of timer and sleep system calls (see
53 below) was also limited by the size of the jiffy.
54
55 Since Linux 2.6.21, Linux supports high-resolution timers (HRTs),
56 optionally configurable via CONFIG_HIGH_RES_TIMERS. On a system that
57 supports HRTs, the accuracy of sleep and timer system calls is no
58 longer constrained by the jiffy, but instead can be as accurate as