PTHREAD_COND_INIT(3P) BSD PTHREAD_COND_INIT(3P)
NAME
pthread_cond_init - Creates a condition variable
SYNOPSIS
#include <pthread.h>
int pthread_cond_init (cond, attr)
pthread_cond_t *cond;
pthread_condattr_t attr;
DESCRIPTION
The pthread_cond_init function creates a condition variable with
attributes specified by the attr argument. If the attr argument is
pthread_condattr_default, the default attributes are used.
The cond argument specifies the address in which the ID for the new
condition variable will be stored; and attr specifies the attributes
object to use in creating the new condition variable.
To have a thread block until some condition is true, use a condition
variable with a mutex. Use the pthread_cond_wait(3P) or
pthread_cond_timedwait(3P) function to cause the calling thread to wait
until the condition is satisfied, and use the pthread_cond_signal(3P) or
pthread_cond_broadcast(3P) function to indicate that the condition has
been satisfied and to wake up the waiting thread(s).
NOTES
This interface is based on draft 4 of the IEEE P1003.4a standard, and
will be changed to conform to the final version.
DIAGNOSTICS
Upon successful completion, the ID of the new condition variable is
stored at *cond, and a value of 0 (zero) is returned. Otherwise, no
condition variable is created, -1 is returned, and errno is set to
indicate the error.
ERRORS
If the pthread_cond_init function fails, errno may be set to one of the
following values:
[EAGAIN] The system lacks the resources necessary for creating another
condition variable.
[EAGAIN] The new condition variable cannot be created without exceeding
the system-imposed limit on the total number of condition
variables allowed for each user.
[ENOMEM] There is not enough memory to create the condition variable.
This is not a temporary condition.
[EINVAL] The value specified by the cond or attr argument is invalid.
SEE ALSO
pthread_cond_destroy(3P), pthread_cond_signal(3P),
pthread_cond_broadcast(3P), pthread_cond_wait(3P),
pthread_cond_timedwait(3P)