summaryrefslogtreecommitdiffstats
path: root/share/man/man7/clocks.7
blob: b32967f9ac37130fb86ed80a5df394c78f70ff6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
.\"
.\" Copyright (c) 1996 Joerg Wunsch
.\"
.\" All rights reserved.
.\"
.\" This program is free software.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD$
.\" "
.Dd April 1, 1996
.Os
.Dt CLOCKS 7
.Sh NAME
.Nm clocks
.Nd various system timers
.Sh SYNOPSIS
.In time.h
.Sh DESCRIPTION
.Dv HZ
is not part of the application interface in
.Bx .
.Pp
There are many different real and virtual (timekeeping) clocks with
different frequencies:
.Bl -bullet
.It
The scheduling clock.
This is a real clock with frequency that happens to be 100.
It is not available to applications.
.It
The statistics clock.
This is a real clock with frequency that happens to be 128.
It is not directly available to applications.
.It
The clock reported by
.Xr clock 3 .
This is a virtual clock with a frequency that happens to be 128.
Its actual frequency is given by the macro
.Dv CLOCKS_PER_SEC .
Note that
.Dv CLOCKS_PER_SEC
may be floating point.
Do not use
.Xr clock 3
in new programs under
.Fx .
It is feeble compared with
.Xr getrusage 2 .
It is provided for \*[Ai]
conformance.
It is implemented by calling
.Xr getrusage 2
and throwing away information and resolution.
.It
The clock reported by
.Xr times 3 .
This is a virtual clock with a frequency that happens to be 128.
Its actual frequency is given by the macro
.Dv CLK_TCK
(deprecated; do not use) and by
.Fn sysconf SC_CLK_TCK
and by
.Xr sysctl 3 .
Note that its frequency may be different from
.Dv CLOCKS_PER_SEC .
Do not use
.Xr times 3
in new programs under
.Fx .
It is feeble compared with
.Xr gettimeofday 2
together with
.Xr getrusage 2 .
It is provided for \*[Px]
conformance.
It is implemented by calling
.Xr gettimeofday 2
and
.Xr getrusage 2
and throwing away information and resolution.
.It
The profiling clock.
This is a real clock with frequency 1024.
It is used mainly by
.Xr moncontrol 3 ,
.Xr kgmon 8
and
.Xr gprof 1 .
Applications should determine its actual frequency using
.Xr sysctl 3
or by reading it from the header in the profiling data file.
.It
The mc146818a clock.
This is a real clock with a nominal frequency of 32768.
It is divided down to give the statistic clock and the profiling clock.
It is not available to applications.
.It
The microseconds clock.
This is a virtual clock with frequency 1000000.
It is used for most timekeeping in
.Bx
and is exported to applications in
.Xr getrusage 2 ,
.Xr gettimeofday 2 ,
.Xr select 2 ,
.Xr getitimer 2 ,
etc.
This is the clock that should normally be used by
.Bx
applications.
.It
The i8254 clock.
This is a real clock/timer with a nominal frequency of 1193182.
It has three independent time counters to be used.
It is divided down to give the scheduling clock.
It is not available to applications.
.It
The TSC clock (64-bit register) on fifth-generation or later x86 systems.
This is a real clock with a frequency that is equivalent to the number of
cycles per second of the CPU(s).
Its frequency can be found using the
.Va machdep.tsc_freq
sysctl, if it is available.
It is used to interpolate between values of the scheduling clock.
It can be accessed using the
.Dv PMIOTSTAMP
request of
.Xr perfmon 4 .
.El
.Pp
Summary: if
.Dv HZ
is not 1000000 then the application is probably using the wrong clock.
.Sh SEE ALSO
.Xr gprof 1 ,
.Xr getitimer 2 ,
.Xr getrusage 2 ,
.Xr gettimeofday 2 ,
.Xr select 2 ,
.Xr clock 3 ,
.Xr moncontrol 3 ,
.Xr times 3
.Sh AUTHORS
.An -nosplit
This man page has been written by
.An J\(:org Wunsch
after a description posted by
.An Bruce Evans .
OpenPOWER on IntegriCloud