Multithreaded Programming Guide

Block For a Specified Interval

pthread_cond_reltimedwait_np(3THR)

Prototype:
int  pthread_cond_reltimedwait_np(pthread_cond_t *cv, 
    pthread_mutex_t *mp, 
   const struct timespec *reltime);
#include <pthread.h>
#include <time.h>

pthread_cond_t cv;
pthread_mutex_t mp;
timestruct_t reltime;
int ret;

/* wait on condition variable */
ret = pthread_cond_reltimedwait_np(&cv, &mp, &reltime); 

Use pthread_cond_reltimedwait_np(3THR) as you would use pthread_cond_timedwait(), except that pthread_cond_reltimedwait_np() takes a relative time interval rather than an absolute future time of day as the value of its last argument. pthread_cond_reltimedwait_np() always returns with the mutex locked and owned by the calling thread, even when it is returning an error. (For Solaris threads, see cond_reltimedwait(3THR).) The pthread_cond_reltimedwait_np() function blocks until the condition is signaled or until the time interval, specified by the last argument, has elapsed.


Note –

pthread_cond_reltimedwait_np() is also a cancellation point.


Return Values

pthread_cond_reltimedwait_np() returns zero after completing successfully. Any other return value indicates that an error occurred. When either of the following conditions occurs, the function fails and returns the corresponding value.


EINVAL

cv or reltime points to an illegal address.


ETIMEDOUT

The time interval specified by reltime has passed.