Open System Services System Calls Reference Manual (G06.25+, H06.03+)

pthread_cond_timedwait(2) OSS System Calls Reference Manual
NAME
pthread_cond_timedwait
- Causes a thread to wait either for a condition variable to be signaled
or broadcast, or for a specic expiration time
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
#include <spthread.h>
int pthread_cond_timedwait(
pthread_cond_t *cond,
pthread_mutex_t *mutex,
const struct timespec *abstime );
PARAMETERS
cond species the condition variable that the calling thread waits on.
mutex species the mutex associated with the condition variable specied by the cond
parameter.
abstime species the absolute time at which the wait expires, if the condition variable
cond has not been signaled or broadcast. See the
pthread_get_expiration_np(2) reference page either online or in the Open Sys-
tem Services System Calls Reference Manual; that function is used to obtain a
value for this parameter. The abstime value is specied in Universal Coordi-
nated Time (UTC).
DESCRIPTION
This function causes a thread to wait until one of the following occurs:
The specied condition variable is signaled or broadcasted.
The current system clock time is greater than or equal to the time specied by the abs-
time parameter.
This function is similar to the pthread_cond_wait() function, except that this function can
return before a condition variable is signaled or broadcast if the specied time expires. For more
information, see the pthread_cond_wait(2) reference page either online or in the Open System
Services System Calls Reference Manual.
This function atomically releases the mutex and causes the calling thread to wait on the condi-
tion variable. When the thread regains control after calling pthread_cond_timedwait(), the
mutex is locked and the thread is the owner, regardless of why the wait ended. If general cance-
lability is enabled, the thread reacquires the mutex (blocking for it if necessary) before the
cleanup handlers are run (or before the exception is raised).
If the current time equals or exceeds the expiration time, this function returns immediately,
releasing and reacquiring the mutex. This function might cause the calling thread to yield (see
the sched_yield(2) reference page either online or in the Open System Services System Calls
Reference Manual). Your code should check the return status whenever this function returns and
take the appropriate action. Otherwise, waiting on the condition variable can become a nonblock-
ing loop.
Call this function after you have locked the mutex specied by mutex. The results of this func-
tion are unpredictable if this function is called before the mutex is locked.
548 Hewlett-Packard Company 527186-003