_lwp_cond_wait(2)


_lwp_cond_wait -- wait on a condition variable

Synopsis

   #include <synch.h>
   

int _lwp_cond_wait(lwp_cond_t *cond, lwp_mutex_t *mutex);

Parameters


cond
pointer to the condition variable to wait for

mutex
pointer to a locked mutex

Description

_lwp_cond_wait allows the calling lightweight process (LWP) to wait for the occurrence of a condition associated with the given object cond.

The mutual exclusion lock (mutex) pointed to by mutex must be locked by the calling LWP upon entry to this routine, otherwise unspecified behavior may result. _lwp_cond_wait automatically releases the mutex, causes the calling LWP to wait on the condition variable cond, and when the condition is signalled or the wait is interrupted, reacquires the mutex and returns to the caller. If the wait is interrupted, mutex is reacquired before a signal handler or any other user code can be executed. The calling LWP is allowed to resume execution when the condition is signaled, broadcast, or interrupted.

A wait on _lwp_cond_wait is interruptible. If _lwp_cond_wait is interrupted the function fails.

cond parameter

The condition variable denoted by cond must previously have been statically initialized (zero-filled).

mutex parameter

mutex is a mutual exclusion variable protecting a shared resource associated with the condition represented by the condition variable, cond. The calling LWP must lock mutex before calling _lwp_cond_wait, otherwise the behavior is unpredictable.

Return values

_lwp_cond_wait returns zero for success and an error number for failure, as described below.

Errors

If any of the following conditions is detected, _lwp_cond_wait fails and returns the corresponding value:

EINVAL
The condition variable pointed to by cond or the mutex pointed to by mutex is invalid.

EFAULT
Either the cond or mutex parameter points to an illegal address. (This error may not be detected; a SIGSEGV signal may be posted to the faulting LWP if an illegal address is used.)

If any of the following conditions occurs, _lwp_cond_wait fails and returns the corresponding value:


EINTR
The operation was interrupted by a signal or a fork operation.

Usage

See the description of how to use condition variables under USAGE on cond_init(3synch).

Because the condition can change between the time the condition is signaled and the mutex is re-locked, the calling LWP must always re-check the condition upon return from cond_wait.

_lwp_cond_wait is never automatically restarted.

References

_lwp_cond_signal(2), _lwp_cond_broadcast(2), _lwp_cond_timedwait(2), cond_broadcast(3synch), cond_destroy(3synch), cond_init(3synch), cond_wait(3synch), cond_signal(3synch), cond_timedwait(3synch), cond_wait(3synch)

Notices

Lightweight processes (LWPs) are internal interfaces and are subject to change. Their use should be avoided.
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004