NPA_MutexTryLock

Tries to obtain a mutex lock without blocking to allow multiprocessor (MP) safe operations on shared data.

Thread Context:Non-Blocking
Requirements:NPA_MutexAlloc must be called one time to initialize the lock before it is used.

Syntax

    LONG NPA_MutexTryLock (
       LONG   mutexHandle
    );
    
    

Parameters

mutexHandle
(IN) Mutex handle obtained from NPA_MutexAlloc.

Return Values

The following table lists return values and descriptions.

0x0000

Successfully obtained lock.

0x0001

Cannot obtain the lock without blocking.

0x1010

Invalid mutex handle.

Remarks

NWPA_MutexTryLock tries to obtain a mutually exclusive lock (only one thread can obtain the lock at any given time) without blocking to manipulate shared data safely in a multiprocessor environment.

It immediately returns a busy status if it cannot obtain the lock without blocking.

It is typically used to avoid dead locks when a predetermined lock ordering must be violated while acquiring multiple mutexes.