Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

clocks(7) [freebsd man page]

CLOCKS(7)					       BSD 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 different frequencies: o The scheduling clock. This is a real clock with frequency that happens to be 100. It is not available to applications. o The statistics clock. This is a real clock with frequency that happens to be 128. It is not 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. Do not use clock(3) in new programs under FreeBSD. It is feeble compared with getrusage(2). It is provided for ANSI conformance. It is implemented by calling getrusage(2) and throwing away informa- tion 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; do not use) and by sysconf(_SC_CLK_TCK) and by sysctl(3). Note that its frequency may be different from CLOCKS_PER_SEC. Do not use times(3) in new programs under FreeBSD. It is feeble compared with gettimeofday(2) together with getrusage(2). It is provided for POSIX conformance. It is implemented by calling gettimeofday(2) and getrusage(2) 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). Applications should determine its actual frequency using sysctl(3) or by reading it from the header in the profiling data file. o 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. 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 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. 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 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 PMIOTSTAMP request of perfmon(4). o 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. Summary: if HZ is not 1000000 then the application is probably using the wrong clock. SEE ALSO
gprof(1), clock_gettime(2), getitimer(2), getrusage(2), gettimeofday(2), select(2), clock(3), moncontrol(3), times(3) AUTHORS
This manual page was written by Jorg Wunsch after a description posted by Bruce Evans. BSD
January 18, 2008 BSD

Check Out this Related Man Page

ntp_adjtime(2)							   System Calls 						    ntp_adjtime(2)

NAME
ntp_adjtime - adjust local clock parameters SYNOPSIS
#include <sys/timex.h> int ntp_adjtime(struct timex *tptr); DESCRIPTION
The ntp_adjtime() function adjusts the parameters used to discipline the local clock, according to the values in the struct timex pointed to by tptr. Before returning, it fills in the structure with the most recent values kept in the kernel. The adjustment is effected in part by speeding up or slowing down the clock, as necessary, and in part by phase-locking onto a once-per second pulse (PPS) provided by a driver, if available. struct timex { uint32_t modes; /* clock mode bits (w) */ int32_t offset; /* time offset (us) (rw) */ int32_t freq; /* frequency offset (scaled ppm) (rw) */ int32_t maxerror; /* maximum error (us) (rw) */ int32_t esterror; /* estimated error (us) (rw) */ int32_t status; /* clock status bits (rw) */ int32_t constant; /* pll time constant (rw) */ int32_t precision; /* clock precision (us) (r) */ int32_t tolerance; /* clock frequency tolerance (scaled ppm) (r) */ int32_t ppsfreq; /* pps frequency (scaled ppm) (r) */ int32_t jitter; /* pps jitter (us) (r) */ int32_t shift; /* interval duration (s) (shift) (r) */ int32_t stabil; /* pps stability (scaled ppm) (r) */ int32_t jitcnt; /* jitter limit exceeded (r) */ int32_t calcnt; /* calibration intervals (r) */ int32_t errcnt; /* calibration errors (r) */ int32_t stbcnt; /* stability limit exceeded (r) */ }; RETURN VALUES
Upon successful completion, ntp_adjtime() returns the current clock state (see <sys/timex.h>). Otherwise, it returns -1 and sets errno to indicate the error. ERRORS
The ntp_adjtime() function will fail if: EFAULT The tptr argument is an invalid pointer. EINVAL The constant member of the structure pointed to by tptr is less than 0 or greater than 30. EPERM The {PRIV_SYS_TIME} privilege is not asserted in the effective set of the calling process. SEE ALSO
xntpd(1M), ntp_gettime(2), privileges(5) SunOS 5.10 1 Feb 2003 ntp_adjtime(2)
Man Page