NXSemaTryWait

Makes a single attempt to acquire the resource protected by a semaphore.

Library:LibC
Classification:NKS
Service:Synchronization

Syntax

  #include <nks/synch.h>
   
  NXBool_t  NXSemaTryWait (
     NXSema_t  *sema);
  

Parameters

sema

(IN) Points to the semaphore to acquire.

Return Values

TRUE

The calling thread owns the specified lock in the specified mode.

FALSE

The calling thread does not own the specified lock in the specified mode.

Remarks

If the semaphore count is greater than zero, NXSemaTryWait decrements the semaphore count and returns TRUE to indicate a successful acquisition of the resource. If the semaphore count is less than or equal to zero, the semaphore cannot be immediately acquired. Because NXSemaTryWait cannot block and wait for the resource to become available, the function returns FALSE to indicate failure and does not modify the semaphore count.

See Also