Open System Services System Calls Reference Manual (G06.25+, H06.03+)
pthread_cond_wait(2) OSS System Calls Reference Manual
NAME
pthread_cond_wait - Causes a thread to wait for the specified condition variable to be signaled
or broadcast
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_wait(
pthread_cond_t *cond,
pthread_mutex_t *mutex );
PARAMETERS
cond specifies the condition variable that the calling thread waits on.
mutex specifies the mutex associated with the condition variable specified by the cond
parameter.
DESCRIPTION
This function causes a thread to wait for the specified condition variable to be signaled or broad-
cast. Each condition corresponds to one or more Boolean relations, called a predicate, based on
shared data. The calling thread waits for the data to reach a particular state for the predicate to
become true. However, return from this function does not imply anything about the value of the
predicate, and it should be reevaluated upon return.
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_wait(), the mutex is
locked and the thread is the owner, regardless of why the wait ended. If general cancelability 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 a thread changes the state of storage protected by the mutex in such a way that a predicate
associated with a condition variable might now be true, that thread must call either the
pthread_cond_signal( ) or pthread_cond_broadcast( ) function for that condition variable. If
neither call is made, any thread waiting on the condition variable continues to wait.
This function might (with low probability) return when the condition variable has not been sig-
naled or broadcast. When this occurs, the mutex is reacquired before the function returns. To
handle this type of situation, enclose each call to this function in a loop that checks the predicate.
The loop documents your intent and protects against spurious wakeups while allowing correct
behavior even if another thread consumes the desired state before the awakened thread runs.
Threads are not allowed to wait on the same condition variable by specifying different mutexes.
Call this function after you have locked the mutex specified by mutex. The results of this func-
tion are unpredictable if this function is called before the mutex is locked.
RETURN VALUES
If an error condition occurs, this function returns an integer value indicating the type of error.
Possible return values are:
0 Successful completion.
5−50 Hewlett-Packard Company 527186-003