CLOCK_NANOSLEEP(2) Linux Programmer s Guide CLOCK_NANOSLEEP(2)

NAME clock_nanosleep - Suspend execution of the currently running thread

SYNOPSIS long sys_clock_nanosleep (clockid_t which_clock, int flags, const struct timespec *rqtp, struct timespec *rmtp);

DESCRIPTION clock_nanosleep suspends execution of the currently running thread un- til the time interval specified by rqtp is elapsed, or until the func- tion is woken up by a signal. The rmtp is updated with the amount of time remaining in the time interval (requested minus sleep time) if non-null. If null, the rmtp argument does not return any remaining time information.

The flags parameter specifies the type of behavior the call will take. So far, the only value defined for this parameter (defined in in- clude/linux.time.h is TIMER_ABSTIME). This value causes the current thread to be suspended from execution in three ways:

1. Until either the time value of the clock specified by clock_id reaches the absolute time specified by the rqtp argument.

2. Until a signal is delivered to the calling thread and its action is to invoke a signal-catching function.

3. Until the process is terminated.

The values that clockid_t currently supports for POSIX.1b timers (de- fined in include/linux/time.h) are:

CLOCK_REALTIME Systemwide realtime clock.

CLOCK_MONOTONIC Represents monotonic time. Cannot be set.

CLOCK_PROCESS_CPUTIME_ID High resolution per-process timer.

CLOCK_THREAD_CPUTIME_ID Thread-specific timer.

CLOCK_REALTIME_HR High resolution version of CLOCK_REALTIME.

CLOCK_MONOTONIC_HR High resolution version of CLOCK_MONOTONIC.

RETURN VALUE clock_nanosleep returns 0 if the time specified by rqtp has elapsed; otherwise, it returns one of the errors listed in the "Errors" section.

ERRORS -EINVAL An invalid which_clock value or an invalid rqtp was specified.

-EFAULT The value was could not be copied to the rmtp or an invalid rqtp value was specified.

SEE ALSO clock_getres(2), clock_gettime(2), clock_settime(2)

AUTHOR Niki Rahimi

Linux 2.6 2004-March-12 CLOCK_NANOSLEEP(2)