![]() |
![]() |
![]() |
Suspend a thread until a timeout or signal occurs
#include <time.h> int nanosleep( const struct timespec* rqtp, struct timespec* rmtp );
libc
The nanosleep() function causes the calling thread to be suspended from execution until either:
Or
The suspension time may be longer than requested because the argument value is rounded up to be a multiple of the system timer resolution or because of scheduling and other system activity.
If the rmtp argument is non-NULL, the timespec structure referenced by it is updated to contain the amount of time remaining in the interval (the requested time minus the time actually slept).
POSIX 1003.1 (Realtime Extensions)
Safety: | |
---|---|
Cancellation point | Yes |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
errno, clock_getres(), clock_gettime(), clock_settime(), sleep(), timer_create(), timer_delete(), timer_gettime(), timer_settime()
![]() |
![]() |
![]() |