Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

pthread_cond_signal(3P)

pthread_cond_broadcast(3P)

PTHREAD_COND_WAIT(3P)                BSD                 PTHREAD_COND_WAIT(3P)



NAME
     pthread_cond_wait - Waits on a condition variable

SYNOPSIS
     #include <pthread.h>

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

DESCRIPTION
     The pthread_cond_wait function unlocks the mutex specified by the mutex
     argument and causes the calling thread to wait on the specified condition
     variable. When the condition is satisfied, the mutex is relocked and the
     function returns.  The condition should be retested after the return to
     ensure the thread has not been erroneously awakened.

     The arguments are as follows:

     cond    Specifies the condition variable to wait on.

     mutex   Specifies the mutex in which the condition variable is located;
             the mutex must be locked by the calling thread.

     Use the pthread_cond_signal(3P) or pthread_cond_broadcast(3P) function to
     indicate that the condition has been satisfied.

NOTES
     This interface is based on draft 4 of the IEEE P1003.4a standard, and
     will be changed to conform to the final version.

EXAMPLE
     pthread_mutex_lock(&mutex);
     while (!condition_true)
            pthread_cond_wait(&cond,&mutex);
     /*
      * condition is valid here
      */
     pthread_mutex_unlock(&mutex);


DIAGNOSTICS
     Upon successful completion, a value of 0 (zero) is returned.  Otherwise,
     -1 is returned and errno is set to indicate the error.

ERRORS
     If the pthread_cond_wait function fails, errno may be set to one of the
     following values:

     [EINVAL]  The value specified by the mutex or cond argument is invalid.

     [EDEADLK] The calling thread is not the owner of mutex.

SEE ALSO
     pthread_cond_signal(3P), pthread_cond_broadcast(3P)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026