Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ pthread_cond_init(3-thr) — Reliant UNIX 5.44c4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

pthread_cond_init(3-thr)                           pthread_cond_init(3-thr)

NAME
     pthreadcondinit - creates a condition variable

SYNOPSIS
     #include <pthread.h>

     int pthreadcondinit(
          pthreadcondt *cond,
          pthreadcondattrt attr);

PARAMETERS
     cond      Condition variable that is created.

     attr      Condition variable attributes object that defines the
               characteristics of the condition variable created. If you
               specify pthreadcondattrdefault, default attributes are
               used.

DESCRIPTION
     The pthreadcondinit() routine creates and initializes a condition
     variable. A condition variable is a synchronization object used in
     conjunction with a mutex. A mutex controls access to shared data; a
     condition variable allows threads to wait for that data to enter a
     defined state. The state is defined by a Boolean expression called a
     predicate.

     A condition variable is signaled or broadcast to indicate that a
     predicate might have become true. The broadcast operation indicates
     that all waiting threads need to resume and reevaluate the predicate.
     The signal operation is used when any one waiting thread can continue.

     If a thread that holds a mutex determines that the shared data is not
     in the correct state for it to proceed (the associated predicate is
     not true), it waits on a condition variable associated with the
     desired state. Waiting on the condition variable automatically
     releases the mutex so that other threads can modify or examine the
     shared data. When a thread modifies the state of the shared data so
     that a predicate might be true, it signals or broadcasts on the
     appropriate condition variable so that threads waiting for that predi-
     cate can continue.

     It is important that all threads waiting on a particular condition
     variable at any time hold the same mutex. If they do not, the behavior
     of the wait operation is unpredictable (an implementation can use the
     mutex to control internal access to the condition variable object).
     However, it is legal for a client to store condition variables and
     mutexes and later reuse them in different combinations. The client
     must ensure that no threads use the condition variable with the old
     mutex. At any time, an arbitrary number of condition variables can be
     associated with a single mutex, each representing a different predi-
     cate of the shared data protected by that mutex.




Page 1                       Reliant UNIX 5.44                Printed 11/98

pthread_cond_init(3-thr)                           pthread_cond_init(3-thr)

     Condition variables are not owned by a particular thread. Any associ-
     ated storage is not automatically deallocated when the creating thread
     terminates.

RETURN VALUES
     If the function fails, errno may be set to one of the following
     values:

     EAGAIN    The system lacks the necessary resources to initialize
               another condition variable.

     EINVAL    Invalid attributes object.

     ENOMEM    Insufficient memory exists to initialize the condition vari-
               able.

SEE ALSO
     pthreadcondbroadcast(3-thr), pthreadconddestroy(3-thr),
     pthreadcondsignal(3-thr), pthreadcondtimedwait(3-thr),
     pthreadcondwait(3-thr).


































Page 2                       Reliant UNIX 5.44                Printed 11/98

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