1CLOCK_NANOSLEEP(2)         Linux Programmer's Manual        CLOCK_NANOSLEEP(2)
2
3
4

NAME

6       clock_nanosleep - high-resolution sleep with specifiable clock
7

SYNOPSIS

9       #include <time.h>
10
11       int clock_nanosleep(clockid_t clockid, int flags,
12                           const struct timespec *request,
13                           struct timespec *remain);
14
15       Link with -lrt (only for glibc versions before 2.17).
16
17   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
18
19       clock_nanosleep():
20           _POSIX_C_SOURCE >= 200112L
21

DESCRIPTION

23       Like nanosleep(2), clock_nanosleep() allows the calling thread to sleep
24       for an interval specified with nanosecond precision.  It differs in al‐
25       lowing  the caller to select the clock against which the sleep interval
26       is to be measured, and in allowing the sleep interval to  be  specified
27       as either an absolute or a relative value.
28
29       The time values passed to and returned by this call are specified using
30       timespec structures, defined as follows:
31
32           struct timespec {
33               time_t tv_sec;        /* seconds */
34               long   tv_nsec;       /* nanoseconds [0 .. 999999999] */
35           };
36
37       The clockid argument specifies the clock against which the sleep inter‐
38       val  is  to  be  measured.  This argument can have one of the following
39       values:
40
41       CLOCK_REALTIME
42              A settable system-wide real-time clock.
43
44       CLOCK_TAI (since Linux 3.10)
45              A system-wide clock derived from wall-clock  time  but  ignoring
46              leap seconds.
47
48       CLOCK_MONOTONIC
49              A nonsettable, monotonically increasing clock that measures time
50              since some unspecified point in the past that  does  not  change
51              after system startup.
52
53       CLOCK_BOOTIME (since Linux 2.6.39)
54              Identical  to  CLOCK_MONOTONIC, except that it also includes any
55              time that the system is suspended.
56
57       CLOCK_PROCESS_CPUTIME_ID
58              A settable per-process clock that measures CPU time consumed  by
59              all threads in the process.
60
61       See  clock_getres(2) for further details on these clocks.  In addition,
62       the   CPU   clock   IDs   returned   by   clock_getcpuclockid(3)    and
63       pthread_getcpuclockid(3) can also be passed in clockid.
64
65       If flags is 0, then the value specified in request is interpreted as an
66       interval relative to the  current  value  of  the  clock  specified  by
67       clockid.
68
69       If  flags  is TIMER_ABSTIME, then request is interpreted as an absolute
70       time as measured by the clock, clockid.  If request  is  less  than  or
71       equal to the current value of the clock, then clock_nanosleep() returns
72       immediately without suspending the calling thread.
73
74       clock_nanosleep() suspends the execution of the  calling  thread  until
75       either  at least the time specified by request has elaps