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: src/share/man/man7/clocks.7,v 1.9.2.5 2001/12/17 11:30:15 ru Exp $ 29.\" $DragonFly: src/share/man/man7/clocks.7,v 1.2 2003/06/17 04:37:00 dillon Exp $ 30.\" " 31.Dd April 1, 1996 32.Os 33.Dt CLOCKS 7 34.Sh NAME 35.Nm clocks 36.Nd various system timers 37.Sh SYNOPSIS 38.In time.h 39.Sh DESCRIPTION 40.Ql HZ 41is not part of the application interface in 42.Bx . 43.Pp 44There are many different real and virtual (timekeeping) clocks with 45different frequencies: 46.Bl -bullet -offset XXX 47.It 48The scheduling clock. This is a real clock with frequency that 49happens to be 100. It isn't available to applications. 50.It 51The statistics clock. This is a real clock with frequency that 52happens to be 128. It isn't directly available to applications. 53.It 54The clock reported by 55.Xr clock 3 . 56This is a virtual clock with a frequency that happens to be 128. Its 57actual frequency is given by the macro 58.Dv CLOCKS_PER_SEC . 59Note that 60.Dv CLOCKS_PER_SEC 61may be floating point. Don't use 62.Fn clock 63in new programs under 64.Fx . 65It is feeble compared with 66.Xr getrusage 2 . 67It is provided for ANSI conformance. It is implemented by calling 68.Fn getrusage 69and throwing away information and resolution. 70.It 71The clock reported by 72.Xr times 3 . 73This is a virtual clock with a frequency that happens to be 128. Its 74actual frequency is given by the macro 75.Dv CLK_TCK 76(deprecated; don't use) and by 77.Fn sysconf SC_CLK_TCK 78and by 79.Xr sysctl 3 . 80Note that its frequency may be different from 81.Dv CLOCKS_PER_SEC . 82Don't use 83.Xr times 3 84in new programs under 85.Fx . 86It is feeble compared with 87.Xr gettimeofday 2 88together with 89.Fn getrusage . 90It is provided for POSIX 91conformance. It is implemented by calling 92.Fn gettimeofday 93and 94.Fn getrusage 95and throwing away information and resolution. 96.It 97The profiling clock. This is a real clock with frequency 1024. 98It is used mainly by 99.Xr moncontrol 3 , 100.Xr kgmon 8 101and 102.Xr gprof 1 . 103Applications should determine its actual frequency using 104.Xr sysctl 3 105or by reading it from the header in the profiling data file. 106.It 107The mc14618a clock. This is a real clock with a nominal frequency of 10832768. It is divided down to give the statistic clock and the profiling 109clock. It isn't available to applications. 110.It 111The microseconds clock. This is a virtual clock with frequency 1121000000. It is used for most timekeeping in 113.Bx 114and is exported 115to applications in 116.Xr getrusage 2 , 117.Xr gettimeofday 2 , 118.Xr select 2 , 119.Xr getitimer 2 , 120etc... This is the clock that should normally be used 121by 122.Bx 123applications. 124.It 125The i8254 clock. This is a real clock/timer with a nominal frequency of 1261193182. It is divided down to give the scheduling clock. It isn't 127available to applications. 128.It 129The TSC clock (64-bit register) on fifth-generation or later x86 systems. 130This is a real clock with a frequency that is equivalent to the number of 131cycles per second of the CPU(s). 132Its frequency can be found using the sysctl 133.Sy machdep.tsc_freq . 134It is used to interpolate between values of the scheduling clock. 135It is only available to applications in a purely machine-dependent manner. 136.El 137.Pp 138Summary: if 139.Ql HZ 140isn't 1000000 then the application is probably using the wrong clock. 141.Sh SEE ALSO 142.Xr gprof 1 , 143.Xr getitimer 2 , 144.Xr getrusage 2 , 145.Xr gettimeofday 2 , 146.Xr select 2 , 147.Xr clock 3 , 148.Xr moncontrol 3 , 149.Xr times 3 150.Sh AUTHORS 151.An -nosplit 152This man page has been written by 153.An J\(:org Wunsch 154after a description posted by 155.An Bruce Evans . 156