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.\" $FreeBSD$ 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.In time.h 38.Sh DESCRIPTION 39.Dv HZ 40is not part of the application interface in 41.Bx . 42.Pp 43There are many different real and virtual (timekeeping) clocks with 44different frequencies: 45.Bl -bullet 46.It 47The scheduling clock. 48This is a real clock with frequency that happens to be 100. 49It is not available to applications. 50.It 51The statistics clock. 52This is a real clock with frequency that happens to be 128. 53It is not directly available to applications. 54.It 55The clock reported by 56.Xr clock 3 . 57This is a virtual clock with a frequency that happens to be 128. 58Its actual frequency is given by the macro 59.Dv CLOCKS_PER_SEC . 60Note that 61.Dv CLOCKS_PER_SEC 62may be floating point. 63Do not use 64.Xr clock 3 65in new programs under 66.Fx . 67It is feeble compared with 68.Xr getrusage 2 . 69It is provided for \*[Ai] 70conformance. 71It is implemented by calling 72.Xr getrusage 2 73and throwing away information and resolution. 74.It 75The clock reported by 76.Xr times 3 . 77This is a virtual clock with a frequency that happens to be 128. 78Its actual frequency is given by the macro 79.Dv CLK_TCK 80(deprecated; do not use) and by 81.Fn sysconf SC_CLK_TCK 82and by 83.Xr sysctl 3 . 84Note that its frequency may be different from 85.Dv CLOCKS_PER_SEC . 86Do not use 87.Xr times 3 88in new programs under 89.Fx . 90It is feeble compared with 91.Xr gettimeofday 2 92together with 93.Xr getrusage 2 . 94It is provided for \*[Px] 95conformance. 96It is implemented by calling 97.Xr gettimeofday 2 98and 99.Xr getrusage 2 100and throwing away information and resolution. 101.It 102The profiling clock. 103This is a real clock with frequency 1024. 104It is used mainly by 105.Xr moncontrol 3 , 106.Xr kgmon 8 107and 108.Xr gprof 1 . 109Applications should determine its actual frequency using 110.Xr sysctl 3 111or by reading it from the header in the profiling data file. 112.It 113The mc146818a clock. 114This is a real clock with a nominal frequency of 32768. 115It is divided down to give the statistic clock and the profiling clock. 116It is not available to applications. 117.It 118The microseconds clock. 119This is a virtual clock with frequency 1000000. 120It is used for most timekeeping in 121.Bx 122and is exported to applications in 123.Xr getrusage 2 , 124.Xr gettimeofday 2 , 125.Xr select 2 , 126.Xr getitimer 2 , 127etc. 128This is the clock that should normally be used by 129.Bx 130applications. 131.It 132The i8254 clock. 133This is a real clock/timer with a nominal frequency of 1193182. 134It has three independent time counters to be used. 135It is divided down to give the scheduling clock. 136It is not available to applications. 137.It 138The TSC clock (64-bit register) on fifth-generation or later x86 systems. 139This is a real clock with a frequency that is equivalent to the number of 140cycles per second of the CPU(s). 141Its frequency can be found using the 142.Va machdep.tsc_freq 143sysctl, if it is available. 144It is used to interpolate between values of the scheduling clock. 145It can be accessed using the 146.Dv PMIOTSTAMP 147request of 148.Xr perfmon 4 . 149.El 150.Pp 151Summary: if 152.Dv HZ 153is not 1000000 then the application is probably using the wrong clock. 154.Sh SEE ALSO 155.Xr gprof 1 , 156.Xr getitimer 2 , 157.Xr getrusage 2 , 158.Xr gettimeofday 2 , 159.Xr select 2 , 160.Xr clock 3 , 161.Xr moncontrol 3 , 162.Xr times 3 163.Sh AUTHORS 164.An -nosplit 165This man page has been written by 166.An J\(:org Wunsch 167after a description posted by 168.An Bruce Evans . 169