Manual Pages for Linux CentOS command on man clock_getres
MyWebUniversity

Manual Pages for Linux CentOS command on man clock_getres

CLOCKGETRES(2) Linux Programmer's Manual CLOCKGETRES(2)

NAME

clockgetres, clockgettime, clocksettime - clock and time functions SYNOPSIS

#include int clockgetres(clockidt clkid, struct timespec *res); int clockgettime(clockidt clkid, struct timespec *tp); int clocksettime(clockidt clkid, const struct timespec *tp);

Link with -lrt (only for glibc versions before 2.17). Feature Test Macro Requirements for glibc (see featuretestmacros(7)): clockgetres(), clockgettime(), clocksettime(): POSIXCSOURCE >= 199309L DESCRIPTION The function clockgetres() finds the resolution (precision) of the

specified clock clkid, and, if res is non-NULL, stores it in the struct timespec pointed to by res. The resolution of clocks depends on the implementation and cannot be configured by a particular process. If the time value pointed to by the argument tp of clocksettime() is not a multiple of res, then it is truncated to a multiple of res. The functions clockgettime() and clocksettime() retrieve and set the time of the specified clock clkid. The res and tp arguments are timespec structures, as specified in : struct timespec { timet tvsec; /* seconds */ long tvnsec; /* nanoseconds */ }; The clkid argument is the identifier of the particular clock on which

to act. A clock may be system-wide and hence visible for all pro‐

cesses, or per-process if it measures time only within a single process.

All implementations support the system-wide real-time clock, which is identified by CLOCKREALTIME. Its time represents seconds and nanosec‐ onds since the Epoch. When its time is changed, timers for a relative interval are unaffected, but timers for an absolute point in time are affected. More clocks may be implemented. The interpretation of the correspond‐ ing time values and the effect on timers is unspecified. Sufficiently recent versions of glibc and the Linux kernel support the following clocks: CLOCKREALTIME

System-wide clock that measures real (i.e., wall-clock) time. Setting this clock requires appropriate privileges. This clock is affected by discontinuous jumps in the system time (e.g., if the system administrator manually changes the clock), and by the incremental adjustments performed by adjtime(3) and NTP.

CLOCKREALTIMECOARSE (since Linux 2.6.32; Linux-specific) A faster but less precise version of CLOCKREALTIME. Use when

you need very fast, but not fine-grained timestamps. CLOCKMONOTONIC Clock that cannot be set and represents monotonic time since some unspecified starting point. This clock is not affected by discontinuous jumps in the system time (e.g., if the system administrator manually changes the clock), but is affected by the incremental adjustments performed by adjtime(3) and NTP.

CLOCKMONOTONICCOARSE (since Linux 2.6.32; Linux-specific) A faster but less precise version of CLOCKMONOTONIC.

Use when you need very fast, but not fine-grained time‐ stamps.

CLOCKMONOTONICRAW (since Linux 2.6.28; Linux-specific) Similar to CLOCKMONOTONIC, but provides access to a raw

hardware-based time that is not subject to NTP adjust‐ ments or the incremental adjustments performed by adj‐ time(3).

CLOCKBOOTTIME (since Linux 2.6.39; Linux-specific) Identical to CLOCKMONOTONIC, except it also includes any time that the system is suspended. This allows applica‐

tions to get a suspend-aware monotonic clock without hav‐ ing to deal with the complications of CLOCKREALTIME, which may have discontinuities if the time is changed using settimeofday(2). CLOCKPROCESSCPUTIMEID

High-resolution per-process timer from the CPU. CLOCKTHREADCPUTIMEID

Thread-specific CPU-time clock. RETURN VALUE clockgettime(), clocksettime() and clockgetres() return 0 for

success, or -1 for failure (in which case errno is set appropri‐ ately). ERRORS EFAULT tp points outside the accessible address space. EINVAL The clkid specified is not supported on this system. EPERM clocksettime() does not have permission to set the clock indicated. CONFORMING TO

SUSv2, POSIX.1-2001. AVAILABILITY On POSIX systems on which these functions are available, the symbol POSIXTIMERS is defined in to a value greater than 0. The symbols POSIXMONOTONICCLOCK, POSIXCPUTIME, POSIXTHREADCPUTIME indicate that CLOCKMONOTONIC, CLOCKPROCESSCPUTIMEID, CLOCKTHREADCPUTIMEID are available. (See also sysconf(3).) NOTES Note for SMP systems The CLOCKPROCESSCPUTIMEID and CLOCKTHREADCPUTIMEID clocks are realized on many platforms using timers from the CPUs (TSC on i386, AR.ITC on Itanium). These registers may differ between CPUs and as a consequence these clocks may return bogus results if a process is migrated to another CPU. If the CPUs in an SMP system have different clock sources then there is no way to maintain a correlation between the timer reg‐ isters since each CPU will run at a slightly different fre‐ quency. If that is the case then clockgetcpuclockid(0) will return ENOENT to signify this condition. The two clocks will then be useful only if it can be ensured that a process stays on a certain CPU. The processors in an SMP system do not start all at exactly the same time and therefore the timer registers are typically run‐ ning at an offset. Some architectures include code that attempts to limit these offsets on bootup. However, the code cannot guarantee to accurately tune the offsets. Glibc contains no provisions to deal with these offsets (unlike the Linux Ker‐ nel). Typically these offsets are small and therefore the effects may be negligible in most cases. BUGS

According to POSIX.1-2001, a process with "appropriate privi‐ leges" may set the CLOCKPROCESSCPUTIMEID and CLOCKTHREADCPUTIMEID clocks using clocksettime(). On Linux, these clocks are not settable (i.e., no process has "appropriate privileges"). SEE ALSO date(1), gettimeofday(2), settimeofday(2), time(2), adjtime(3), clockgetcpuclockid(3), ctime(3), ftime(3), pthreadgetcpu‐ clockid(3), sysconf(3), time(7) COLOPHON

This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at

http://www.kernel.org/doc/man-pages/.

2013-02-25 CLOCKGETRES(2)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™