pthread_cond_init(3T) DG/UX R4.11MU05 pthread_cond_init(3T)
NAME
pthreadcondinit, pthreadconddestroy - initialize or destroy
condition variables
SYNOPSIS
#include <pthread.h>
int pthreadcondinit(pthreadcondt *cond,
pthreadcondattrt *attr);
int pthreadconddestroy(pthreadcondt *cond);
where:
cond A pointer to a condition variable
attr A pointer to an condition attributes object, or NULL
DESCRIPTION
The pthreadcondinit() function initializes the condition variable
pointed to by cond with attributes specified by attr. If attr is
NULL the default condition attributes are used; the effect is the
same as passing the address of a newly initialized condition
attributes object.
If the pthreadcondinit() function fails, the condition variable is
not initialized and the contents of the condition variable are
undefined.
The pthreadconddestroy() function destroys the condition variable
pointed to by cond. Destroying a condition variable upon which other
threads are currently blocked or upon which other threads have yet to
execute operations results in undefined behavior.
DIAGNOSTICS
Returns
If successful, the functions returns 0. Otherwise they return -1 and
set errno to indicate the error.
Errors
For each of the following conditions, pthreadcondinit() returns -1
and sets errno to the corresponding value:
[EAGAIN] The system lacked the necessary resources to initialize
another condition variable. In DG/UX, this occurs when
trying to initialize a process-shared condition variable,
and the system-imposed limit on the number of global
synchronization queues (for process-shared mutexes and
condition variables) has been exceeded.
[ENOMEM] Insufficient memory exists to initialize the condition
variable. In DG/UX, this occurs when trying to allocate
more global synchronization queues in order to initialize a
process-shared condition variable.
For each of the following conditions, pthreadconddestroy() returns
-1 and sets errno to the corresponding value:
[EBUSY] The system has detected an attempt to destroy a condition
variable while it is referenced (for example, while being
used in a call to pthreadcondwait() or
pthreadcondtimedwait() by another thread).
[EINVAL] The value specified by cond is invalid. This occurs when
DG/UX has detected that cond does not point to a properly
initialized condition variable.
SEE ALSO
pthreadcondbroadcast(3T), pthreadcondsignal(3T),
pthreadcondtimedwait(3T), pthreadcondwait(3T), threads(5).
NOTES
The terms "condition" and "condition variable" are equivalent.
The kernel configuration variable MAXGLOBALSQS can be used to change
the system-imposed limit on the number of global synchronization
queues used for process-shared mutexes and condition variables.
If a condition variable is initialized as process-shared, the
underlying global synchronization queues are not automatically
cleaned up if the process terminates or the shared memory area
holding the condition variable is deallocated. They can only be
released by calls to pthreadconddestroy() on the condition
variable. An application that uses process-shared condition
variables should ensure that it properly destroys all process-shared
condition variables in order to avoid a leak of global
synchronization queues.
DG/UX does not currently allocate any extra memory in order to
initialize condition variables that are not process-shared.
Licensed material--property of copyright holder(s)