table of contents
other versions
- wheezy 3.44-1
- jessie 3.74-1
- jessie-backports 4.10-2~bpo8+1
- testing 4.10-2
- unstable 4.10-2
CLOCK_NANOSLEEP(2) | Linux Programmer's Manual | CLOCK_NANOSLEEP(2) |
NAME¶
clock_nanosleep - high-resolution sleep with specifiable clockSYNOPSIS¶
#include <time.h>int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *request, struct timespec *remain);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
_XOPEN_SOURCE >= 600 ||
_POSIX_C_SOURCE >= 200112L
DESCRIPTION¶
Like nanosleep(2), clock_nanosleep() allows the calling thread to sleep for an interval specified with nanosecond precision. It differs in allowing the caller to select the clock against which the sleep interval is to be measured, and in allowing the sleep interval to be specified as either an absolute or a relative value.struct timespec { time_t tv_sec; /* seconds */ long tv_nsec; /* nanoseconds [0 .. 999999999] */ };
- CLOCK_REALTIME
- A settable system-wide real-time clock.
- CLOCK_MONOTONIC
- A nonsettable, monotonically increasing clock that measures time since some unspecified point in the past that does not change after system startup.
- CLOCK_PROCESS_CPUTIME_ID
- A settable per-process clock that measures CPU time consumed by all threads in the process.
RETURN VALUE¶
On successfully sleeping for the requested interval, clock_nanosleep() returns 0. If the call is interrupted by a signal handler or encounters an error, then it returns one of the positive error number listed in ERRORS.ERRORS¶
- EFAULT
- request or remain specified an invalid address.
- EINTR
- The sleep was interrupted by a signal handler.
- EINVAL
- The value in the tv_nsec field was not in the range 0 to 999999999 or tv_sec was negative.
- EINVAL
- clock_id was invalid. (CLOCK_THREAD_CPUTIME_ID is not a permitted value for clock_id.)
VERSIONS¶
The clock_nanosleep() system call first appeared in Linux 2.6. Support is available in glibc since version 2.1.CONFORMING TO¶
POSIX.1-2001.NOTES¶
If the interval specified in request is not an exact multiple of the granularity underlying clock (see time(7)), then the interval will be rounded up to the next multiple. Furthermore, after the sleep completes, there may still be a delay before the CPU becomes free to once again execute the calling thread.SEE ALSO¶
clock_getres(2), nanosleep(2), timer_create(2), sleep(3), usleep(3), time(7)COLOPHON¶
This page is part of release 3.44 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/.2012-11-07 | Linux |