cond_timedwait

Waits on the condition variable for a limited time.

Library:LibC
Classification:UNIX International
Service:Synchronization

Syntax

  #include <synch.h>
   
  int  cond_timedwait (
     cond_t        *cvp,
     mutex_t       *mp,
     timestruc_t   *abstime );
  

Parameters

cvp

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

mp

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

abstime

(IN) Points to a structure that specifies the length of time to wait. See timespec_t, which is also called timestruct_t, timespec, and timestrc_t.

Return Values

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

Decimal

Constant

Description

60

ETIMEDOUT

The specified time has expired.

Remarks

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

It is the responsibility of the calling thread to re-evaluate the entry condition when cond_timedwait returns. The condition might have been consumed by a different thread between the time when a blocked thread within cond_timedwait awakens.

If the condition is not signaled (with respect to the calling thread) by the specified time, cond_timedwait returns ETIMEDOUT.

See Also