NXCondTimedWait

Waits on the condition variable for a limited time.

Library:LibC
Classification:NKS
Service:Synchronization

Syntax

  #include <nks/synch.h>
   
  int NXCondTimedWait(
     NXCond_t       *cond, 
     NXMutex_t      *mutex,
     unsigned long   interval);
  

Parameters

cond

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

mutex

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

interval

(IN) Specifies the maximum amount of time you are willing to wait (expressed in the number of system ticks from the point of blocking).

Return Values

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

Decimal

Hex

Constant

Description

60

0x22

NX_ETIMEDOUT

The specified time interval expired.

63

0x3F

NX_EINTR

The wait was interrupted.

Remarks

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

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

Two cases are viewed as errors:

  • The wait can be interrupted, in which case NXCondTimedWait returns NX_EINTR.

  • If the condition is not signaled (with respect to the calling thread) within the specified interval (measured from the point of blocking), the interval expires and NXCondTimedWait returns NX_ETIMEDOUT.

If an error occurs, the entry lock is not held when NXCondTimedWait returns.

See Also

NXCondWait