dg_pthread_sleep(3T) DG/UX 5.4R3.00 dg_pthread_sleep(3T)
NAME
dgpthreadsleep - sleep with nanosecond granularity
SYNOPSIS
#include <pthread.h>
#include <timers.h>
int dgpthreadsleep(const struct timespec *sleeptimeptr,
struct timespec *unslepttimeptr);
where:
sleeptimeptr
A pointer to the relative amount of time to sleep
unslepttimeptr
A pointer to a location to receive the unslept time, or NULL
DESCRIPTION
The dgpthreadsleep causes the calling thread to sleep for the
amount of time specified in the struct timespec pointed to by
sleeptimeptr or until some kind of software interruption occurs
(e.g., a signal). In either case, this routine returns 0 and, if
unslepttimeptr is not NULL, the amount of unslept time is stored in
the struct timespec pointed to by unslepttimeptr.
If this call returns with unslept time, the caller cannot necessarily
assume that a signal has been processed. This call may spuriously
return with unslept time at any point. Proper use of this function
typically involves calling it in a loop until the unslept time counts
down to zero.
This call is a pthread cancellation point, as are the sleep() family
of calls.
DIAGNOSTICS
Returns
The dgpthreadsleep() function always succeeds and returns 0.
SEE ALSO
sleep(3T), pthreadcondtimedwait(3T).
NOTES
The main advantage of this function is that it allows threads to
sleep with nanosecond granularity without having to use
pthreadcondtimedwait(). Unlike pthreadcondtimedwait(),
dgpthreadsleep() sleeps for a relative amount of time from the
present instead of until an absolute time point in the future.
However, this call is not portable.
The final standard will likely include a similar function, called
nanosleep(), that accepts a struct timespec. In such a case,
dgpthreadsleep() may be phased out eventually.
Licensed material--property of copyright holder(s) 1