Locks the specified mutex.
#include <nks/synch.h> int NXLock( NXMutex_t *mutex);
(IN) Points to the mutex to lock. It is expected that the hierarchy value of this mutex is greater than any of the mutexes that might be currently held by this context. (For a discussion on lock hierarchy, see NXMutexAlloc or NXMutexInit.)
If successful, returns 0; otherwise returns a nonzero error code:
NXLock acquires the specified mutually exclusive lock. If the lock being acquired is not free (is held by a different context), the calling thread waits until the lock can be acquired. No assumptions can be made about the way the calling thread might wait for the lock to become free. The mutex is not guaranteed to be FIFO.
NKS mutexes are nonrecursive by default. If you are using a nonrecursive mutex in debug mode and try to acquire the mutex that you already locked, an assertion is generated with a message containing the filename and the line number of the offending call.
NXLock is a macro unless NDEBUG is defined; otherwise, it consumes NXMutexTestFlag, a function which should only be used for debugging and which produces an assertion if the mutex is used recursively. In production code, NDEBUG should be defined.
For sample code, see Mutex.c.