cond_wait(3scl)cond_wait(3scl)NAMEcond_wait - Causes a thread to wait for the specified condition vari‐
able to be signaled or broadcasted.
LIBRARY
SCL Threads Library (libthread.so)
SYNOPSIS
#include <synch.h>
int cond_wait(
cond_t *condp,
mutex_t *mutexp );
PARAMETERS
Address of the condition variable that the calling thread waits on.
Address of the mutex associated with the condition variable specified
by condp.
DESCRIPTION
This routine causes a thread to wait for the specified condition vari‐
able to be signaled or broadcasted.
This routine should be called with the specified mutex locked. The
results of this routine are unpredictable if this routine is called
without first locking the mutex.
This routine atomically unlocks the mutex and causes the calling thread
to wait on the condition. The atomicity is important, because it means
the thread cannot miss a wakeup while the mutex is being unlocked. When
the wait is satisfied as a result of some other thread calling
pthread_cond_signal(3) or pthread_cond_broadcast(3), the mutex is re-
locked before returning to the caller.
SCL IMPLEMENTATION NOTEScond_wait(3scl) is implemented by calling pthread_cond_wait(3).
Before calling pthread_cond_wait(3), this routine first checks whether
the condition variable and mutex are valid: if not, then this routine
initializes them for intra-process use (type USYNC_THREAD) by calling
pthread_cond_init(3) and/or pthread_mutex_init(3). If the mutex needed
initializing, then this routine also locks the mutex by calling
pthread_mutex_lock(3). This action matches the observed behaviour of
Solaris.
Solaris documents that cond_wait() always returns with the mutex
locked, even when returning an error. This is not necessarily the case
with the SCL implementation, if, for example, the specified mutex is
invalid, and the attempt to initialize the mutex, and then lock it,
fails. The best we can say is that if cond_wait(3scl) is called with
valid condp and mutexp parameters, and with the mutex locked, and
cond_wait(3scl) returns 0, then the caller is assured that the mutex is
now locked. The state of the mutex for any other status return is unde‐
fined in this implementation.
RETURN VALUES
If an error condition occurs, this routine returns an integer value
indicating the type of error.
Additional error return information may be written to the SCL error
log. Refer to scl_error_log(4scl) for details.
Possible return values are as follows: Successful completion. An
internal implementation error occurred. Refer to the SCL errorlog for
additional information.
Note: EFAULT is not returned if condp or mutexp is an illegal address.
An illegal address generates a SIGSEGV signal, which by default will
abort the process and generate a core dump.
ERRORS
None.
RELATED INFORMATION
Functions: cond_broadcast(3scl), cond_destroy(3scl), cond_init(3scl),
cond_signal(3scl), cond_timedwait(3scl), pthread_cond_init(3),
pthread_cond_wait(3), pthread_mutex_init(3), pthread_mutex_lock(3),
scl_intro(3scl), scl_thread_intro(3scl)
Files: scl_error_log(4scl)
Manuals: Solaris Compatibility Libraries User's Guide
cond_wait(3scl)