Section: Linux Programmer's Manual (7)
Return to Main Contents
time - overview of time and timers
Real time and process time
is defined as time measured from some fixed point,
either from a standard point in the past
(see the description of the Epoch and calendar time below),
or from some point (e.g., the start) in the life of a process
is defined as the amount of CPU time used by a process.
This is sometimes divided into
User CPU time is the time spent executing code in user mode.
System CPU time is the time spent by the kernel executing
in system mode on behalf of the process (e.g., executing system calls).
command can be used to determine the amount of CPU time consumed
during the execution of a program.
A program can determine the amount of CPU time it has consumed using
The Hardware Clock
Most computers have a (battery-powered) hardware clock which the kernel
reads at boot time in order to initialize the software clock.
For further details, see
The Software Clock, HZ, and Jiffies
The accuracy of various system calls that set timeouts,
and measure CPU time (e.g.,
is limited by the resolution of the
a clock maintained by the kernel which measures time in
The size of a jiffy is determined by the value of the kernel constant
The value of
varies across kernel versions and hardware platforms.
On i386 the situation is as follows:
on kernels up to and including 2.4.x, HZ was 100,
giving a jiffy value of 0.01 seconds;
starting with 2.6.0, HZ was raised to 1000, giving a jiffy of
Since kernel 2.6.13, the HZ value is a kernel
configuration parameter and can be 100, 250 (the default) or 1000,
yielding a jiffies value of, respectively, 0.01, 0.004, or 0.001 seconds.
Since kernel 2.6.20, a further frequency is available:
300, a number that divides evenly for the common video
frame rates (PAL, 25 HZ; NTSC, 30 HZ).
system call is a special case.
It reports times with a granularity defined by the kernel constant
Userspace applications can determine the value of this constant using
Before Linux 2.6.21, the accuracy of timer and sleep system calls
(see below) was also limited by the size of the jiffy.
Since Linux 2.6.21, Linux supports high-resolution timers (HRTs),
optionally configurable via
On a system that supports HRTs, the accuracy of sleep and timer
system calls is no longer constrained by the jiffy,
but instead can be as accurate as the hardware allows
(microsecond accuracy is typical of modern hardware).
You can determine whether high-resolution timers are supported by
checking the resolution returned by a call to
or looking at the "resolution" entries in
HRTs are not supported on all hardware architectures.
(Support is provided on x86, arm, and powerpc, among others.)
Unix systems represent time in seconds since the
1970-01-01 00:00:00 +0000 (UTC).
A program can determine the
which returns time (in seconds and microseconds) that have
elapsed since the Epoch;
provides similar information, but only with accuracy to the
The system time can be changed using
Certain library functions use a structure of
which stores time value separated out into distinct components
(year, month, day, hour, minute, second, etc.).
This structure is described in
which also describes functions that convert between calendar time and
Functions for converting between broken-down time and printable
string representations of the time are described in
Sleeping and Setting Timers
Various system calls and functions allow a program to sleep
(suspend execution) for a specified period of time; see
Various system calls allow a process to set a timer that expires
at some point in the future, and optionally at repeated intervals;
This page is part of release 3.27 of the Linux
A description of the project,
and information about reporting bugs,
can be found at
- Real time and process time
- The Hardware Clock
- The Software Clock, HZ, and Jiffies
- High-Resolution Timers
- The Epoch
- Broken-down time
- Sleeping and Setting Timers
- SEE ALSO
This document was created by
using the manual pages.