1clock_nanosleep(3C)      Standard C Library Functions      clock_nanosleep(3C)
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 clock_id, int flags,
12            const struct timespec *rqtp, struct timespec *rmtp);
13
14

DESCRIPTION

16       If  the  flag  TIMER_ABSTIME  is  not  set  in  the flags argument, the
17       clock_nanosleep() function causes the current thread  to  be  suspended
18       from  execution  until  either  the time interval specified by the rqtp
19       argument has elapsed, or a signal is delivered to  the  calling  thread
20       and  its action is to invoke a signal-catching function, or the process
21       is terminated. The clock used to measure the time is the  clock  speci‐
22       fied by clock_id.
23
24
25       If   the   flag  TIMER_ABSTIME  is  set  in  the  flags  argument,  the
26       clock_nanosleep() function causes the current thread  to  be  suspended
27       from  execution  until  either the time value of the clock specified by
28       clock_id reaches the absolute time specified by the rqtp argument, or a
29       signal is delivered to the calling thread and its action is to invoke a
30       signal-catching function, or the process is terminated. If, at the time
31       of  the call, the time value specified by rqtp is less than or equal to
32       the time value of the specified clock, then  clock_nanosleep()  returns
33       immediately and the calling process is not suspended.
34
35
36       The  suspension  time  caused  by  this  function  can  be  longer than
37       requested because the argument value is rounded up to an integer multi‐
38       ple  of  the  sleep  resolution,  or because of the scheduling of other
39       activity by the system. But, except for the case of  being  interrupted
40       by  a  signal,  the  suspension time for the relative clock_nanosleep()
41       function (that is, with the TIMER_ABSTIME flag not  set)  will  not  be
42       less  than the time interval specified by rqtp, as measured by the cor‐
43       responding clock. The suspension  for  the  absolute  clock_nanosleep()
44       function  (that  is, with the TIMER_ABSTIME flag set) will be in effect
45       at least until the value of the corresponding clock reaches  the  abso‐
46       lute  time  specified by rqtp, except for the case of being interrupted
47       by a signal.
48
49
50       The use of the clock_nanosleep() function has no effect on  the  action
51       or blockage of any signal.
52
53
54       The clock_nanosleep() function fails if the clock_id argument refers to
55       the CPU-time clock of the calling thread. It is unspecified if clock_id
56       values of other CPU-time clocks are allowed.
57

RETURN VALUES

59       If  the  clock_nanosleep()  function returns because the requested time
60       has elapsed, its return value is 0.
61
62
63       If the clock_nanosleep() function returns because it  has  been  inter‐
64       rupted  by  a signal, it returns the corresponding error value. For the
65       relative clock_nanosleep() function, if the rmtp argument is  non-null,
66       the  timespec  structure  referenced  by  it  is updated to contain the
67       amount of time remaining in the interval (the requested time minus  the
68       time  actually slept). If the rmtp argument is NULL, the remaining time
69       is not returned. The absolute clock_nanosleep() function has no  effect
70       on the structure referenced by rmtp.
71
72
73       If  clock_nanosleep()  fails,  it  shall return the corresponding error
74       value.
75

ERRORS

77       The clock_nanosleep() function will fail if:
78
79       EINTR      The clock_nanosleep() function was interrupted by a signal.
80
81
82       EINVAL     The rqtp argument specified a  nanosecond  value  less  than
83                  zero  or  greater  than  or  equal  to 1,000 million; or the
84                  TIMER_ABSTIME flag was specified in flags and the rqtp argu‐
85                  ment  is  outside  the  range  for  the  clock  specified by
86                  clock_id; or the clock_id argument does not specify a  known
87                  clock,  or  specifies  the  CPU-time  clock  of  the calling
88                  thread.
89
90
91       ENOTSUP    The  clock_id  argument  specifies   a   clock   for   which
92                  clock_nanosleep()  is  not  supported,  such  as  a CPU-time
93                  clock.
94
95

ATTRIBUTES

97       See attributes(5) for descriptions of the following attributes:
98
99
100
101
102       ┌─────────────────────────────┬─────────────────────────────┐
103       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
104       ├─────────────────────────────┼─────────────────────────────┤
105       │Interface Stability          │Committed                    │
106       ├─────────────────────────────┼─────────────────────────────┤
107       │MT-Level                     │MT-Safe                      │
108       ├─────────────────────────────┼─────────────────────────────┤
109       │Standard                     │See standards(5).            │
110       └─────────────────────────────┴─────────────────────────────┘
111

SEE ALSO

113       clock_getres(3C), nanosleep(3C), pthread_cond_timedwait(3C), sleep(3C),
114       attributes(5), standards(5)
115
116
117
118SunOS 5.11                        5 Feb 2008               clock_nanosleep(3C)
Impressum