1TIME(7) Linux Programmer's Manual TIME(7)
2
3
4
6 time - overview of time
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 many system calls and timestamps is limited by the res‐
31 olution of the software clock, a clock maintained by the kernel which
32 measures time in jiffies. The size of a jiffy is determined by the
33 value of the kernel constant HZ. The value of HZ varies across kernel
34 versions and hardware platforms. On x86 the situation is as follows:
35 on kernels up to and including 2.4.x, HZ was 100, giving a jiffy value
36 of 0.01 seconds; starting with 2.6.0, HZ was raised to 1000, giving a
37 jiffy of 0.001 seconds; since kernel 2.6.13, the HZ value is a kernel
38 configuration parameter and can be 100, 250 (the default) or 1000,
39 yielding a jiffies value of, respectively, 0.01, 0.004, or 0.001 sec‐
40 onds. Since kernel 2.6.20, a further frequency is available: 300, a
41 number that divides evenly for the common video frame rates (PAL, 25
42 HZ; NTSC, 30 HZ).
43
44 The Epoch
45 Unix systems represent time in seconds since the Epoch, which is
46 defined as 0:00:00 UTC on the morning of 1 January 1970.
47
48 A program can determine the calendar time using gettimeofday(2), which
49 returns time (in seconds and microseconds) that have elapsed since the
50 Epoch; time(2) provides similar information, but only with accuracy to
51 the nearest second. The system time can be changed using settimeof‐
52 day(2).
53
54 Broken-down time
55 Certain library functions use a structure of type tm to represent bro‐
56 ken-down time, which stores time value separated out into distinct com‐
57 ponents (year, month, day, hour, minute, second, etc.). This structure
58 is described in ctime(3), which also describes functions that convert
59 between calendar time and broken-down time. Functions for converting
60 between broken-down time and printable string representations of the
61 time are described in ctime(3), strftime(3), and strptime(3).
62
63 Sleeping and Setting Timers
64 Various system calls and functions allow a program to sleep (suspend
65 execution) for a specified period of time; see nanosleep(2) and
66 sleep(3).
67
68 Various system calls allow a process to set a timer that expires at
69 some point in the future, and optionally at repeated intervals; see
70 alarm(2), getitimer(2), and timer_create(3).
71
73 date(1), time(1), adjtimex(2), alarm(2), getitimer(2), getrlimit(2),
74 getrusage(2), gettimeofday(2), nanosleep(2), stat(2), time(2),
75 times(2), utime(2), adjtime(3), clock(3), sleep(3), ctime(3), strf‐
76 time(3), strptime(3), usleep(3), rtc(4), hwclock(8).
77
78
79
80Linux 2.6.16 2006-04-28 TIME(7)