NANOSLEEP(2) NANOSLEEP(2)
nanosleep - high resolution sleep
#include <time.h>
int nanosleep(const struct timespec *rqtp, struct timespec *rmtp);
The nanosleep system call causes the current thread to suspend until
either the time interval specified by the rqtp argument has elapsed or a
signal is delivered to the calling thread and its action is to invoke a
signal-handling function or terminate the process.
The suspension time will be rounded to a multiple of the underlying
system-provided sleep resolution. For processes that have requested a
timeout of less then the base clock tick of 10 milliseconds, this
resolution is defined by the variable fasthz which may be examined or
modified using systune(1M). Real-Time processes will use a resolution
equal to the processor cycle time. Otherwise, the resolution is
determined by the length of a clock tick. The length of a clock tick is
defined by CLK_TCK in the include file <limits.h>.
sleep(3), sginap(2), alarm(2), pause(2), schedctl(2), timers(5),
realtime(5).
If the calling thread remains suspended for the requested time interval,
nanosleep returns 0. If, however, the thread is interrupted prematurely
by a signal, it returns -1 and sets errno to indicate the interruption.
If the rmtp argument is non-NULL, the timespec structure referenced by it
contains the amount of time remaining in the interval.
If any of the following conditions occur, nanosleep returns -1 and sets
errno to indicate the error:
[EFAULT] An argument address referenced invalid memory.
[EINTR] nanosleep was interrupted by a signal.
[EINVAL] The rqtp argument specified a nanosecond value less than
zero or greater than
or equal to 1000 million.
PPPPaaaaggggeeee 1111 [ Back ]
|