Skip site navigation (1)Skip section navigation (2)

FreeBSD Man Pages

Man Page or Keyword Search:
Man Architecture
Apropos Keyword Search (all sections) Output format
home | help
CLOCKS(7)	   FreeBSD Miscellaneous Information Manual	     CLOCKS(7)

NAME
     clocks -- various system timers

SYNOPSIS
     #include <time.h>

DESCRIPTION
     `HZ' is not part of the application interface in BSD.

     There are many different real and virtual (timekeeping) clocks with dif-
     ferent frequencies:

	+o   The	scheduling clock.  This	is a real clock	with frequency that
	    happens to be 100.	It isn't available to applications.

	+o   The	statistics clock.  This	is a real clock	with frequency that
	    happens to be 128.	It isn't directly available to applications.

	+o   The	clock reported by clock(3).  This is a virtual clock with a
	    frequency that happens to be 128.  Its actual frequency is given
	    by the macro CLOCKS_PER_SEC.  Note that CLOCKS_PER_SEC may be
	    floating point.  Don't use clock() in new programs under FreeBSD.
	    It is feeble compared with getrusage(2).  It is provided for ANSI
	    conformance.  It is	implemented by calling getrusage() and throw-
	    ing	away information and resolution.

	+o   The	clock reported by times(3).  This is a virtual clock with a
	    frequency that happens to be 128.  Its actual frequency is given
	    by the macro CLK_TCK (deprecated; don't use) and by
	    sysconf(SC_CLK_TCK)	and by sysctl(3).  Note	that its frequency may
	    be different from CLOCKS_PER_SEC.  Don't use times(3) in new pro-
	    grams under	FreeBSD.  It is	feeble compared	with gettimeofday(2)
	    together with getrusage().	It is provided for POSIX conformance.
	    It is implemented by calling gettimeofday()	and getrusage()	and
	    throwing away information and resolution.

	+o   The	profiling clock.  This is a real clock with frequency 1024.
	    It is used mainly by moncontrol(3),	kgmon(8) and gprof(1).	Appli-
	    cations should determine its actual	frequency using	sysctl(3) or
	    by reading it from the header in the profiling data	file.

	+o   The	mc14618a 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 isn't available to applications.

	+o   The	microseconds clock.  This is a virtual clock with frequency
	    1000000.  It is used for most timekeeping in BSD and is exported
	    to applications in getrusage(2), gettimeofday(2), select(2),
	    getitimer(2), etc...  This is the clock that should	normally be
	    used by BSD	applications.

	+o   The	i8254 clock.  This is a	real clock/timer with a	nominal	fre-
	    quency of 1193182.	It is divided down to give the scheduling
	    clock.  It isn't available to applications.

	+o   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 sysctl machdep.tsc_freq.  It	is used	to
	    interpolate	between	values of the scheduling clock.	 It is only
	    available to applications in a purely machine-dependent manner.

     Summary: if `HZ' isn't 1000000 then the application is probably using the
     wrong clock.

SEE ALSO
     gprof(1), getitimer(2), getrusage(2), gettimeofday(2), select(2),
     clock(3), moncontrol(3), times(3)

AUTHORS
     This man page has been written by Jorg Wunsch after a description posted
     by	Bruce Evans.

FreeBSD	10.1			 April 1, 1996			  FreeBSD 10.1

NAME | SYNOPSIS | DESCRIPTION | SEE ALSO | AUTHORS

Want to link to this manual page? Use this URL:
<http://www.freebsd.org/cgi/man.cgi?query=clocks&sektion=7&manpath=FreeBSD+4.5-RELEASE>

home | help