Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)

pthread_cond_init(2) OSS System Calls Reference Manual
NAME
pthread_cond_init - Initializes a condition variable
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
32-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/yputdll
H-series and J-series OSS processes that use the Standard POSIX Threads library:
/G/system/zdllnnn/zsptdll
SYNOPSIS
#include <pthread.h> | #include <spthread.h>
/* pthread.h is required to use POSIX User Thread Model library */
/* spthread.h is required to use Standard POSIX Threads library */
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.
On systems running H06.21 or later H-series RVUs or J06.10 or later J-series RVUs, you can use
either the POSIX User Thread Model library or the Standard POSIX Threads library for threaded
applications.
To use this function in a threaded application that uses the POSIX User Thread Model library on
systems running H06.21 or later RVUs or J06.10 or later RVUs, you must perform all of the fol-
lowing tasks:
Include the pthread.h header file in the application.
588 Hewlett-Packard Company 527186-023