14.6. Pthread Cond Functions

14.6.1. The pthread_cond_broadcast function

Synopsis
#include <pthread.h>

int pthread_cond_broadcast (pthread_cond_t * cond );

Description

The pthread_cond_broadcast function unblocks all threads that are waiting on the given condition variable.

Returns

The pthread_cond_broadcast function returns zero if the call is successful, otherwise it sets errno to EINVAL and returns -1.

Implementation Notes

None.

14.6.2. The pthread_cond_destroy function

Synopsis
#include <pthread.h>

int pthread_cond_destroy (pthread_cond_t * cond );

Description

The pthread_cond_destroy function destroys the given condition variable. If the variable has one or more waiting threads then errno is set to EBUSY.

Returns

The pthread_cond_destroy function returns zero if the call is successful, otherwise it sets errno and returns -1.

Implementation Notes

None.

14.6.3. The pthread_cond_init function

Synopsis
#include <pthread.h>

int pthread_cond_init (pthread_cond_t * cond , pthread_condattr_t * attr );

Description

The pthread_cond_init function initializes the given condition variable.

Returns

The pthread_cond_init function returns zero if the call is successful, otherwise it sets errno to EINVAL and returns -1.

Implementation Notes

14.6.4. The pthread_cond_signal function

Synopsis
#include <pthread.h>

int pthread_cond_signal (pthread_cond_t * cond );

Description

The pthread_cond_signal function unblocks at least one thread waiting on a condition variable. The scheduling priority determines which thread is runs next.

Returns

The pthread_cond_signal function returns zero if the call is successful, otherwise it sets errno to EINVAL and returns -1.

Implementation Notes

None.

14.6.5. The pthread_cond_timedwait function

Synopsis
#include <pthread.h>

int pthread_cond_timedwait (pthread_cond_t * cond , pthread_mutex_t * mutex , struct timespec * timeout );

Description

The pthread_cond_timedwait function unlocks the given mutex and places the calling thread into blocked state. When the specified condition variable is signaled or broadcast, or the system time is greater than i or equal to timeout, this function re-locks the mutex and returns to the caller.

Returns

The pthread_cond_timedwait function returns zero if the call is successful, otherwise it sets errno to EINVAL and returns -1.

Implementation Notes

None.

14.6.6. The pthread_cond_wait function

Synopsis
#include <pthread.h>

int pthread_cond_wait (pthread_cond_t * cond , pthread_mutex_t * mutex );

Description

The pthread_cond_wait function unlocks the given mutex and places the calling thread into a blocked state. When the specified condition variable is signaled or broadcast, this function re-locks the mutex and returns to the caller.

Returns

The pthread_cond_wait function returns zero if the call is successful, otherwise it sets errno to EINVAL and returns -1.

Implementation Notes

None.