Semaphore Support
2-10
2.3
Semaphore Support
2.3.1
Synopsis
The semaphore object provides a method of manipulating counting sema-
phores using a generic handle.
Semaphores can be used for both task synchronization and mutual exclusion.
2.3.2
Function Overview
The Semaphore Object access functions (in functional order) are as follows:
SemCreate()
Create new semaphore
SemDelete()
Delete semaphore
SemPend()
Wait on semaphore, optionally for a period of time
SemCount()
Get the current semaphore count
SemPost()
Release semaphore – increment count
SemReset()
Reset semaphore and set new count
2.3.3
Semaphore API Functions
Create New Semaphore
SemCreate
Syntax
HANDLE SemCreate( int Count );
Parameter(s)
Count
Initial semaphore count
Return Value
Handle to semaphore or NULL on error
Description
Creates a new semaphore object with an initial count.
Get Current Semaphore Count
SemCount
Syntax
int SemCount( HANDLE hSem );
Parameter(s)
hSem
Handle to Semaphore
Return Value
Current semaphore count
Description
Returns the current count of the semaphore object.