Open System Services System Calls Reference Manual (G06.28+, H06.05+)
System Functions (n - p) pthread_cond_init(2)
NAME
pthread_cond_init - Initializes a condition variable
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_init(
pthread_cond_t *cond,
const pthread_condattr_t *
attr );
PARAMETERS
cond specifies the condition variable to be initialized.
attr specifies the condition variable attributes object that defines the characteristics
of the condition variable to be initialized.
DESCRIPTION
This function initializes the condition variable specified by the cond parameter with attributes
indicated by the attr parameter. If the value of attr is NULL, the default condition variable attri-
butes are used.
A condition variable is a synchronization object used with a mutex. A mutex controls access to
data that is shared among threads; a condition variable allows threads to wait for that data to
enter a defined state.
Condition variables are not owned by a particular thread. Any associated storage is not automat-
ically deallocated when the creating thread terminates.
If the default condition variable attributes are appropriate, use the macro
PTHREAD_COND_INITIALIZER to initialize statically allocated condition variables. The
effect of using this macro is the same as the effect of calling pthread_cond_init() with an attr
parameter of NULL. To call this macro, specify:
pthread_cond_t condition = PTHREAD_COND_INITIALIZER
;
When statically initialized, a condition variable should not also be used in the
pthread_cond_init() function.
RETURN VALUES
If an error condition occurs, this function returns an integer value indicating the type of error, the
condition variable is not initialized, and the contents of cond are undefined. Possible return
values are:
0 Successful completion.
[EAGAIN] One of the following conditions exists:
• The system lacks the necessary resources to initialize another condition
variable.
• The system-imposed limit on the total number of condition variables
under execution by a single user is exceeded.
527186-007 Hewlett-Packard Company 5−55