ExamineSemaphore

Returns the current value and open count of a local semaphore

Local Servers:nonblocking
Remote Servers:blocking
Classification:3.x, 4.x, 5.x, 6.x
Service:Server-Based Synchronization

Syntax

  #include <\nlm\nit\nwsync.h>  
   
  int ExamineSemaphore (  
     long    semaphoreHandle,  
     int    *semaphoreValue,  
     WORD   *openCount); 
  

Parameters

semaphoreHandle
(IN) Specifies the semaphore handle of an open semaphore.
semaphoreValue
(OUT) Receives current semaphore value (-127 to 127).
openCount
(OUT) Receives the number of processes that currently have the semaphore opened.

Return Values

Decimal

Hex

Constant

0

(0x00)

ESUCCESS

255

(0xFF)

ERR_INVALID_SEMAPHORE_HANDLE

Remarks

For cross-platform functionality, call NWExamineSemaphore.

The semaphoreValue is decremented for each WaitOnSemaphore and incremented for each SignalSemaphore. A positive semaphoreValue indicates that the application can access the associated network resource. If semaphoreValue is zero or negative, the application must either enter a waiting queue by calling the function WaitOnSemaphore, or temporarily abandon its attempt to access the network resource.

The openCount indicates the number of processes holding the semaphore open. OpenSemaphore increments this value. CloseSemaphore decrements this value.

See Also

CloseSemaphore, OpenSemaphore, SignalSemaphore, WaitOnSemaphore