NXUnlock

Unlocks the specified mutex.

Library:LibC
Classification:NKS
Service:Synchronization

Syntax

  #include <nks/synch.h>
   
  int NXUnlock (
     NXMutex_t  *mutex);
  

Parameters

mutex

(IN) Points to the mutex to unlock.

Return Values

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

Decimal

Hex

Constant

Description

9

0x09

NX_EINVAL

The mutex parameter is not a valid mutex.

Remarks

No assumptions should be made about the order in which threads waiting for a mutex actually acquire the mutex. The mutex is not guaranteed to be FIFO.

The thread attempting to release the mutex must own the mutex. If a thread attempts to release a mutex it does not own, a warning is asserted.

NXUnlock is a macro unless NDEBUG is defined; otherwise, it consumes NXMutexDepth, a function which should only be used for debugging and which produces an assertion if you attempt to unlock a mutex that you don't currently have locked. In production code, NDEBUG should be defined.

For sample code, see Mutex.c.

See Also