pthread_cond_init

Initializes a specified condition variable.

Library:LibC
Classification:POSIX
Service:Synchronization

Syntax

  #include <pthread.h>
   
  int   pthread_cond_init  (
     pthread_cond_t             *cond,
     const pthread_condattr_t   *attr);
  

Parameters

cond

(IN) Points to the condition variable to be initialized.

attr

(IN) Points to a structure containing the condition variable attributes. If NULL, the condition variable is initialized as private (PTHREAD_PROCESS_PRIVATE). On NetWare, condition variables cannot currently be shared.

Return Values

If successful, returns zero; otherwise, returns a nonzero error code:

Decimal

Constant

Description

5

ENOMEM

Insufficient memory to complete the call.

Remarks

Condition variables can be used to support event-based synchronization where a lock or a semaphore might not be appropriate.

If you call pthread_cond_init on a previously initialized condition variable, no warning is given unless you are in DEBUG mode.

See Also