NXCondWait

Waits on the condition variable.

Library:LibC
Classification:NKS
Service:Synchronization

Syntax

  #include nks/synch.h>
   
  int  NXCondWait (
     NXCond_t    *cond,
     NXMutex_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

Hex

Constant

Description

63

0x3F

NX_EINTR

The wait was interrupted

Remarks

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

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

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

For sample code, see CondVar.c.

See Also