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

clocks(2)							System Calls Manual							 clocks(2)

NAME
clock_settime(), clock_gettime(), clock_getres() - clock operations SYNOPSIS
DESCRIPTION
clock_settime() The function sets the specified clock, to the value specified by Time values that are between two consecutive non-negative integer multi- ples of the resolution of the specified clock are truncated down to the smaller multiple of the resolution. clock_gettime() The function returns the current value for the specified clock, clock_getres() The resolution of any clock can be obtained by calling Clock resolutions are implementation defined and are not settable by a process. If the argument is not NULL, the resolution of the specified clock is stored into the location pointed to by If is NULL, the clock resolution is not returned. A clock may be system wide, that is, visible to all processes; or per-process, measuring time that is meaningful only within a process. The following clocks are supported: This clock represents the realtime clock for the system. For this clock, the values returned by and specified by represent the amount of time (in seconds and nanoseconds) since the Epoch. It is a system wide clock. The privilege is required to set this clock. Processes owned by the superuser have this privilege. Processes owned by other users may have this privilege, depending on system configuration. See privileges(5) for more information about privileged access on systems that support fine-grained privileges. This clock represents the amount of time (in seconds and nanoseconds) that the calling process has spent executing code in the user's context. It is a per-process clock. It cannot be set by the user. This clock represents the amount of time (in seconds and nanoseconds) that the calling process has spent executing code in both the user's context and in the operating system on behalf of the calling process. It is a per-process clock. It cannot be set by the user. These clocks are high resolution hardware clocks present on HP-RT realtime systems. It is included here so that applications accessing this hardware can be compiled on HP-UX systems and then ported to an HP-RT target. HP-UX does not support or RETURN VALUE
A return of zero indicates that the call succeeded. A return value of -1 indicates that an error occurred, and is set to indicate the error. ERRORS
If any of the following conditions occur, the and functions return -1 and set (see errno(2)) to the corresponding value: The functions and are not supported by this implementation. The argument does not specify a known clock. The argument to is outside the range for the given The argument specified a nanosecond value less than zero or greater than or equal to 1000 million. The requesting process does not have the necessary privileges to set the specified clock. The or argument points to an invalid address. EXAMPLES
Advance the system wide realtime clock approximately one hour: Get the resolution of the user profiling clock: AUTHOR
and were derived from the proposed IEEE POSIX P1003.4 Standard, Draft 14. SEE ALSO
timers(2), privileges(5). STANDARDS CONFORMANCE
clocks(2)
Man Page