1DTK_NANOSLEEP(3)              Draw Toolkit manual             DTK_NANOSLEEP(3)
2
3
4

NAME

6       dtk_nanosleep - high-resolution sleep
7

SYNOPSIS

9       #include <dtk_time.h>
10
11       int dtk_nanosleep(int abs, const struct dtk_timespec* req,
12                                  struct dtk_timespec* rem);
13

DESCRIPTION

15       The function dtk_nanosleep() allows the caller to sleep for an interval
16       with nanosecond precision. If the argument abs is zero,  the  specified
17       interval  is  interpretated  as a relative value, otherwise an absolute
18       value. The interval is specified by the req argument which is a pointer
19       to a dtk_timespec structure defined as:
20
21           struct dtk_timespec {
22               long sec;    /* seconds */
23               long nsec;   /* nanoseconds */
24           };
25
26       If interpreted as an absolute value, it represents seconds and nanosecā€
27       onds since the Epoch, 1970-01-01 00:00:00 +0000  (UTC).
28
29       dtk_nanosleep() suspends the execution  of  the  calling  thread  until
30       either  at  least the time specified by req has elapsed, or a signal is
31       delivered that causes a signal handler to be called or that  terminates
32       the process.
33
34       If the call is interrupted by a signal handler, dtk_nanosleep() returns
35       -1, and sets errno to EINTR. In addition, if rem is not NULL,  and  abs
36       is  zero,  it returns the remaining unslept time in rem. This value can
37       then be used to call dtk_nanosleep() again and  complete  a  (relative)
38       sleep.
39

RETURN VALUE

41       On  successfully  sleeping  for the requested interval, dtk_nanosleep()
42       returns 0. If the call is interrupted by a signal handler or encounters
43       an error, then it returns -1 and errno is set appropriately.
44

ERRORS

46       dtk_nanosleep() will fail if:
47
48       EINTR  The sleep was interrupted by a signal handler.
49
50       EINVAL The  value in the nsec field was not in the range 0 to 999999999
51              or sec was negative.
52

NOTE

54       This function is a wrapper to clock_nanosleep(2) if it is  provided  by
55       the  system.  Otherwise,  it implements the function by using the sleep
56       function with the highest precision available on the system.
57

SEE ALSO

59       dtk_nanosleep(3), clock_nanosleep(2)
60
61
62
63
64EPFL                                 2011                     DTK_NANOSLEEP(3)
Impressum