NXRwLockInit

Initializes a reader-writer lock.

Library:LibC
Classification:NKS
Service:Synchronization

Syntax

  #include <nks/synch.h>
   
  int NXRwLockInit (
     NXRwLock_t            *lock, 
     NXHierarchy_t          hierarchy, 
     const NXLockInfo_t    *info);
  

Parameters

lock

(IN) Points to the reader-writer lock to be initialized.

hierarchy

(IN) Specifies the hierarchy value to be associated with the mutex. It specifies the order in which this mutex can be acquired relative to other mutexes a context can own. If a context wants to acquire a mutex unconditionally, this value for the mutex being acquired must be greater than the value of any mutexes that the context is currently holding.

info

(IN) Points to the information block to be associated with the reader-writer lock.

Return Values

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

Decimal

Hex

Constant

Description

5

0x05

NX_ENOMEM

Insufficient memory to complete this call

Remarks

Mutually exclusive locks are acquired by threads on behalf of the context that they might be hosting.

Imposing strict ordering among all locks in the application that can be held by a context at the same time avoids deadlock. Hierarchy violations are checked only if the application is built with the compilation option, DEBUG and _LOCKTEST.

Nonrecursive mutexes can be implemented to work faster.

If you call NXRwLockInit on a previously initialized lock, no warning is given unless you are in DEBUG mode.

See Also