pthread_cond_wait

Waits on the condition variable.

Library:LibC
Classification:POSIX
Service:Synchronization

Syntax

  #include <pthread.h>
   
  int   pthread_cond_wait (
     pthread_cond_t    *cond,
     pthread_mutex_t   *mutex);
  

Parameters

cond

(IN) Points to the condition variable to wait on.

mutex

(IN) Points to a mutually exclusive lock held by the calling thread.

Return Values

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

Decimal

Constant

Description

5

ENOMEM

Insufficient memory to complete the call.

9

EINVAL

The cond parameter is invalid.

Remarks

The pthread_cond_wait function atomically releases the entry lock pointed to by mutex and blocks the calling thread. When the condition is signaled, pthread_cond_wait returns.

It is the responsibility of the calling thread to re-evaluate the entry condition when pthread_cond_wait returns. The condition may have been consumed by a different thread between the time when a blocked thread within pthread_cond_wait awakens and when it acquires the entry mutex.

The wait can be interrupted, in which case pthread_cond_wait returns EINTR. In this case, the entry lock is not held when pthread_cond_wait returns.

See Also