1996-04-05 08:51:22 +00:00
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1996-04-05 08:51:22 +00:00
|
|
|
.\" "
|
2008-01-18 12:13:05 +00:00
|
|
|
.Dd January 18, 2008
|
1996-04-05 08:51:22 +00:00
|
|
|
.Os
|
|
|
|
.Dt CLOCKS 7
|
|
|
|
.Sh NAME
|
1996-04-07 21:12:10 +00:00
|
|
|
.Nm clocks
|
1996-04-05 08:51:22 +00:00
|
|
|
.Nd various system timers
|
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In time.h
|
1996-04-05 08:51:22 +00:00
|
|
|
.Sh DESCRIPTION
|
2002-03-17 15:02:20 +00:00
|
|
|
.Dv HZ
|
2001-08-14 10:01:54 +00:00
|
|
|
is not part of the application interface in
|
|
|
|
.Bx .
|
1996-04-05 08:51:22 +00:00
|
|
|
.Pp
|
|
|
|
There are many different real and virtual (timekeeping) clocks with
|
|
|
|
different frequencies:
|
2002-03-17 15:02:20 +00:00
|
|
|
.Bl -bullet
|
1996-04-05 08:51:22 +00:00
|
|
|
.It
|
2002-03-17 15:02:20 +00:00
|
|
|
The scheduling clock.
|
|
|
|
This is a real clock with frequency that happens to be 100.
|
|
|
|
It is not available to applications.
|
1996-04-05 08:51:22 +00:00
|
|
|
.It
|
2002-03-17 15:02:20 +00:00
|
|
|
The statistics clock.
|
|
|
|
This is a real clock with frequency that happens to be 128.
|
|
|
|
It is not directly available to applications.
|
1996-04-05 08:51:22 +00:00
|
|
|
.It
|
|
|
|
The clock reported by
|
|
|
|
.Xr clock 3 .
|
2002-03-17 15:02:20 +00:00
|
|
|
This is a virtual clock with a frequency that happens to be 128.
|
|
|
|
Its actual frequency is given by the macro
|
2001-07-14 19:41:16 +00:00
|
|
|
.Dv CLOCKS_PER_SEC .
|
1996-04-08 04:18:31 +00:00
|
|
|
Note that
|
|
|
|
.Dv CLOCKS_PER_SEC
|
2002-03-17 15:02:20 +00:00
|
|
|
may be floating point.
|
|
|
|
Do not use
|
|
|
|
.Xr clock 3
|
1997-03-21 20:14:15 +00:00
|
|
|
in new programs under
|
2000-11-14 11:20:58 +00:00
|
|
|
.Fx .
|
1997-03-21 20:14:15 +00:00
|
|
|
It is feeble compared with
|
1996-04-05 08:51:22 +00:00
|
|
|
.Xr getrusage 2 .
|
2002-11-26 17:55:41 +00:00
|
|
|
It is provided for
|
|
|
|
.Tn ANSI
|
2002-03-17 15:02:20 +00:00
|
|
|
conformance.
|
|
|
|
It is implemented by calling
|
|
|
|
.Xr getrusage 2
|
1996-04-07 21:12:10 +00:00
|
|
|
and throwing away information and resolution.
|
1996-04-05 08:51:22 +00:00
|
|
|
.It
|
|
|
|
The clock reported by
|
|
|
|
.Xr times 3 .
|
2002-03-17 15:02:20 +00:00
|
|
|
This is a virtual clock with a frequency that happens to be 128.
|
|
|
|
Its actual frequency is given by the macro
|
1996-04-08 04:18:31 +00:00
|
|
|
.Dv CLK_TCK
|
2002-03-17 15:02:20 +00:00
|
|
|
(deprecated; do not use) and by
|
2008-01-18 12:13:05 +00:00
|
|
|
.Fn sysconf _SC_CLK_TCK
|
1996-04-07 21:12:10 +00:00
|
|
|
and by
|
1996-04-05 08:51:22 +00:00
|
|
|
.Xr sysctl 3 .
|
1996-04-08 04:18:31 +00:00
|
|
|
Note that its frequency may be different from
|
|
|
|
.Dv CLOCKS_PER_SEC .
|
2002-03-17 15:02:20 +00:00
|
|
|
Do not use
|
1996-04-07 21:12:10 +00:00
|
|
|
.Xr times 3
|
1997-03-21 20:14:15 +00:00
|
|
|
in new programs under
|
2000-11-14 11:20:58 +00:00
|
|
|
.Fx .
|
1997-03-21 20:14:15 +00:00
|
|
|
It is feeble compared with
|
1996-04-07 21:12:10 +00:00
|
|
|
.Xr gettimeofday 2
|
2001-07-14 19:41:16 +00:00
|
|
|
together with
|
2002-03-17 15:02:20 +00:00
|
|
|
.Xr getrusage 2 .
|
2002-11-26 17:55:41 +00:00
|
|
|
It is provided for
|
|
|
|
.Tn POSIX
|
2002-03-17 15:02:20 +00:00
|
|
|
conformance.
|
|
|
|
It is implemented by calling
|
|
|
|
.Xr gettimeofday 2
|
1996-04-07 21:12:10 +00:00
|
|
|
and
|
2002-03-17 15:02:20 +00:00
|
|
|
.Xr getrusage 2
|
1996-04-07 21:12:10 +00:00
|
|
|
and throwing away information and resolution.
|
1996-04-05 08:51:22 +00:00
|
|
|
.It
|
2002-03-17 15:02:20 +00:00
|
|
|
The profiling clock.
|
|
|
|
This is a real clock with frequency 1024.
|
1996-04-05 08:51:22 +00:00
|
|
|
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
|
2002-03-17 15:02:20 +00:00
|
|
|
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.
|
1996-04-05 08:51:22 +00:00
|
|
|
.It
|
2002-03-17 15:02:20 +00:00
|
|
|
The microseconds clock.
|
|
|
|
This is a virtual clock with frequency 1000000.
|
|
|
|
It is used for most timekeeping in
|
2001-08-14 10:01:54 +00:00
|
|
|
.Bx
|
2002-03-17 15:02:20 +00:00
|
|
|
and is exported to applications in
|
1996-04-05 08:51:22 +00:00
|
|
|
.Xr getrusage 2 ,
|
|
|
|
.Xr gettimeofday 2 ,
|
|
|
|
.Xr select 2 ,
|
|
|
|
.Xr getitimer 2 ,
|
2002-03-17 15:02:20 +00:00
|
|
|
etc.
|
|
|
|
This is the clock that should normally be used by
|
2001-08-14 10:01:54 +00:00
|
|
|
.Bx
|
|
|
|
applications.
|
1996-04-05 08:51:22 +00:00
|
|
|
.It
|
2002-03-17 15:02:20 +00:00
|
|
|
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.
|
1996-04-05 08:51:22 +00:00
|
|
|
.It
|
2000-07-28 21:48:58 +00:00
|
|
|
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).
|
2002-03-17 15:02:20 +00:00
|
|
|
Its frequency can be found using the
|
|
|
|
.Va machdep.tsc_freq
|
|
|
|
sysctl, if it is available.
|
2000-07-28 21:48:58 +00:00
|
|
|
It is used to interpolate between values of the scheduling clock.
|
2002-03-17 15:02:20 +00:00
|
|
|
It can be accessed using the
|
|
|
|
.Dv PMIOTSTAMP
|
|
|
|
request of
|
2002-01-09 13:10:18 +00:00
|
|
|
.Xr perfmon 4 .
|
2005-02-24 20:28:41 +00:00
|
|
|
.It
|
|
|
|
The ACPI clock.
|
|
|
|
This is a real clock/timer with a nominal frequency of 3579545.
|
|
|
|
It is accessed via a 24 or 32 bit register.
|
|
|
|
Unlike the TSC clock, it maintains a constant tick rate even when the CPU
|
|
|
|
sleeps or its clock rate changes.
|
|
|
|
It is not available to applications.
|
1996-04-05 08:51:22 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Summary: if
|
2002-03-17 15:02:20 +00:00
|
|
|
.Dv HZ
|
|
|
|
is not 1000000 then the application is probably using the wrong clock.
|
1996-04-05 08:51:22 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr gprof 1 ,
|
2002-11-29 11:39:20 +00:00
|
|
|
.Xr clock_gettime 2 ,
|
1996-04-05 08:51:22 +00:00
|
|
|
.Xr getitimer 2 ,
|
|
|
|
.Xr getrusage 2 ,
|
|
|
|
.Xr gettimeofday 2 ,
|
|
|
|
.Xr select 2 ,
|
|
|
|
.Xr clock 3 ,
|
|
|
|
.Xr moncontrol 3 ,
|
|
|
|
.Xr times 3
|
|
|
|
.Sh AUTHORS
|
2000-11-22 09:35:58 +00:00
|
|
|
.An -nosplit
|
2005-06-30 13:04:25 +00:00
|
|
|
This manual page was written by
|
2000-11-10 17:46:15 +00:00
|
|
|
.An J\(:org Wunsch
|
1998-03-12 07:31:21 +00:00
|
|
|
after a description posted by
|
|
|
|
.An Bruce Evans .
|