xref: /freebsd/share/man/man7/clocks.7 (revision df7f5d4de4592a8948a25ce01e5bddfbb7ce39dc)
1.\"
2.\" Copyright (c) 1996 Joerg Wunsch
3.\"
4.\" All rights reserved.
5.\"
6.\" This program is free software.
7.\"
8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions
10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright
12.\"    notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\"    notice, this list of conditions and the following disclaimer in the
15.\"    documentation and/or other materials provided with the distribution.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.\" $Id$
29.\" "
30.Dd April 1, 1996
31.Os
32.Dt CLOCKS 7
33.Sh NAME
34.Nm clocks
35.Nd various system timers
36.Sh SYNOPSIS
37.Fd #include <time.h>
38.Sh DESCRIPTION
39.Ql HZ
40is not part of the application interface in BSD.
41.Pp
42There are many different real and virtual (timekeeping) clocks with
43different frequencies:
44.Bl -bullet -offset XXX
45.It
46The scheduling clock.  This is a real clock with frequency that
47happens to be 100.  It isn't available to applications.
48.It
49The statistics clock.  This is a real clock with frequency that
50happens to be 128.  It isn't directly available to applications.
51.It
52The clock reported by
53.Xr clock 3 .
54This is a virtual clock with a frequency that happens to be 128.  It's
55actual frequency is given by the macro
56.Dv CLOCKS_PER_SEC .
57Note that
58.Dv CLOCKS_PER_SEC
59may be floating point.  Don't use
60.Fn clock
61in new programs under FreeBSD.  It is feeble compared with
62.Xr getrusage 2 .
63It is provided for ANSI conformance.  It is implemented by calling
64.Fn getrusage
65and throwing away information and resolution.
66.It
67The clock reported by
68.Xr times 3 .
69This is a virtual clock with a frequency that happens to be 128.  It's
70actual frequency is given by the macro
71.Dv CLK_TCK
72(deprecated; don't use) and by
73.Fn sysconf SC_CLK_TCK
74and by
75.Xr sysctl 3 .
76Note that its frequency may be different from
77.Dv CLOCKS_PER_SEC .
78Don't use
79.Xr times 3
80in new programs under FreeBSD.  It is feeble compared with
81.Xr gettimeofday 2
82together with
83.Fn getrusage .
84It is provided for POSIX
85conformance.  It is implemented by calling
86.Fn gettimeofday
87and
88.Fn getrusage
89and throwing away information and resolution.
90.It
91The profiling clock.  This is a real clock with frequency 1024.
92It is used mainly by
93.Xr moncontrol 3 ,
94.Xr kgmon 8
95and
96.Xr gprof 1 .
97Applications should determine its actual frequency using
98.Xr sysctl 3
99or by reading it from the header in the profiling data file.
100.It
101The mc14618a clock.  This is a real clock with a nominal frequency of
10232768.  It is divided down to give the statistic clock and the profiling
103clock.  It isn't available to applications.
104.It
105The microseconds clock.  This is a virtual clock with frequency
1061000000.  It is used for most timekeeping in BSD and is exported
107to applications in
108.Xr getrusage 2 ,
109.Xr gettimeofday 2 ,
110.Xr select 2 ,
111.Xr getitimer 2 ,
112etc...  This is the clock that should normally be used
113by BSD applications.
114.It
115the i8254 clock.  This is a real clock with a nominal frequency of
1161193182.  It is divided down to give the scheduling clock.  It isn't
117available to applications.
118.It
119the i586 clock on i586 systems.  This is a real clock with a frequency
120of up to 200000000.  It is used to interpolate between values of the
121scheduling clock.  It isn't available to applications.
122.El
123.Pp
124Summary: if
125.Ql HZ
126isn't 1000000 then the application is probably using the wrong clock.
127.Sh SEE ALSO
128.Xr gprof 1 ,
129.Xr getitimer 2 ,
130.Xr getrusage 2 ,
131.Xr gettimeofday 2 ,
132.Xr select 2 ,
133.Xr clock 3 ,
134.Xr moncontrol 3 ,
135.Xr times 3
136.Sh AUTHORS
137This man page has been written by
138.ie t J\(:org Wunsch
139.el Joerg Wunsch
140after a description posted by Bruce Evans.
141