.\" 2003-08-24 aeb, large parts rewritten
.\" 2004-08-06 Christoph Lameter <clameter@sgi.com>, SMP note
.\"
-.TH CLOCK_GETRES 2 2013-02-25 "" "Linux Programmer's Manual"
+.TH CLOCK_GETRES 2 2013-12-28 "" "Linux Programmer's Manual"
.SH NAME
clock_getres, clock_gettime, clock_settime \- clock and time functions
.SH SYNOPSIS
which may have discontinuities if the time is changed using
.BR settimeofday (2).
.TP
-.B CLOCK_PROCESS_CPUTIME_ID
-High-resolution per-process timer from the CPU.
+.BR CLOCK_PROCESS_CPUTIME_ID " (since Linux 2.6.12)"
+Per-process CPU-time clock
+(measures CPU time consumed by all threads in the process).
.TP
-.B CLOCK_THREAD_CPUTIME_ID
+.BR CLOCK_THREAD_CPUTIME_ID " (since Linux 2.6.12)"
Thread-specific CPU-time clock.
.SH RETURN VALUE
.BR clock_gettime (),
.B EPERM
.BR clock_settime ()
does not have permission to set the clock indicated.
+.SH VERSIONS
+These system calls first appeared in Linux 2.6.
.SH CONFORMING TO
SUSv2, POSIX.1-2001.
.SH AVAILABILITY
(See also
.BR sysconf (3).)
.SH NOTES
-.SS Note for SMP systems
-The
+.SS Historical note for SMP systems
+Before Linux added kernel support for
.B CLOCK_PROCESS_CPUTIME_ID
and
-.B CLOCK_THREAD_CPUTIME_ID
-clocks are realized on many platforms using timers from the CPUs
+.BR CLOCK_THREAD_CPUTIME_ID ,
+glibc implemented these clocks on many platforms using timer
+registers from the CPUs
(TSC on i386, AR.ITC on Itanium).
These registers may differ between CPUs and as a consequence
these clocks may return
.B bogus results
if a process is migrated to another CPU.
.PP
-If the CPUs in an SMP system have different clock sources then
+If the CPUs in an SMP system have different clock sources, then
there is no way to maintain a correlation between the timer registers since
each CPU will run at a slightly different frequency.
-If that is the case then
+If that is the case, then
.I clock_getcpuclockid(0)
will return
.B ENOENT
Kernel).
Typically these offsets are small and therefore the effects may be
negligible in most cases.
+
+Since glibc 2.4,
+the wrapper functions for the system calls described in this page avoid
+the abovementioned problems by employing the kernel implementation of
+.B CLOCK_PROCESS_CPUTIME_ID
+and
+.BR CLOCK_THREAD_CPUTIME_ID ,
+on systems that provide such an implementation
+(i.e., Linux 2.6.12 and later).
.SH BUGS
According to POSIX.1-2001, a process with "appropriate privileges" may set the
.B CLOCK_PROCESS_CPUTIME_ID
.BR pthread_getcpuclockid (3),
.BR sysconf (3),
.BR time (7)
+.SH COLOPHON
+This page is part of release 3.65 of the Linux
+.I man-pages
+project.
+A description of the project,
+and information about reporting bugs,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.