NAME

nanosleep - high resolution sleep

SYNOPSIS

#include <time.h>

int nanosleep(const struct timespec *rqtp , struct timespec *rmtp );
struct timespec {
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
int usleep(useconds_t useconds);
int sleep( unsigned int seconds);

DESCRIPTION

nanosleep() suspends the current thread from execution until either the time interval specified by rqtp has elapsed. The suspension time may be longer than requested because the argument value is rounded up to an integer multiple of the sleep resolution or because of the scheduling of other activity by the system. The suspension time will not be less than the time specified by rqtp, as measured by the system clock, CLOCK_REALTIME.

usleep() provides similar functionality to nanosleep() except that the longest possible specified sleep will be less than one second, and the time is specified in microseconds.

sleep() provides a sleep function with time specified in seconds. It has a separate manpage.

RETURN VALUES

If nanosleep() returns because the requested time has elapsed, it returns 0. If rmtp is non-NULL, the timespec structure referenced by rmtp will be updated to contain the remaining amount of time between rqtp and the time actually slept.

If any of the following error conditions occur, nanosleep() returns -1 and sets errno to indicate the error condition.

usleep() does not sleep if the number of microseconds is more than one second. A -1 is returned and errno is set to indicate the number of microseconds requested was greater than one second.

ERRORS

EINVAL
rqtp specified a nanosecond value less than zero or greater than or equal to 1,000,000,000.

SEE ALSO

sleep()




< Copyright Rowebots Research Inc. and Multiprocessor Toolsmiths Inc. 1987-2011 >