1time(7) Miscellaneous Information 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., se‐
31 lect(2), sigtimedwait(2)) and measure CPU time (e.g., getrusage(2)) is
32 limited by the resolution of the software clock, a clock maintained by
33 the kernel which measures time in jiffies. The size of a jiffy is de‐
34 termined 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 Linux 2.4.x, HZ was 100, giving a jiffy value of 0.01 seconds; starting
39 with Linux 2.6.0, HZ was raised to 1000, giving a jiffy of 0.001 sec‐
40 onds. Since Linux 2.6.13, the HZ value is a kernel configuration pa‐
41 rameter and can be 100, 250 (the default) or 1000, yielding a jiffies
42 value of, respectively, 0.01, 0.004, or 0.001 seconds. Since Linux
43 2.6.20, a further frequency is available: 300, a number that divides
44 evenly for the common 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 System and process clocks; time namespaces
52 The kernel supports a range of clocks that measure various kinds of
53 elapsed and virtual (i.e., consumed CPU) time. These clocks are de‐
54 scribed in clock_gettime(2). A few of the clocks are settable using
55 clock_settime(2). The values of certain clocks are virtualized by time
56 namespaces; see time_namespaces(7).
57
58 High