Creates a named or unnamed semaphore object.
Kernel.bdh
CreateSemaphore(in nSecurity : number, in nInitCount : number, in nMaxCount : number, in sName : string): number;
handle to the semaphore object
Parameter | Description |
---|---|
nSecurity | Security attributes for the semaphore object. This parameter must always be set to NULL. |
nInitCount |
Initial count for the semaphore object. This value must be greater than or equal to zero and less than or equal to nMaxCount. The initial count value is not set if the specified semaphore object already exists. |
nMaxCount |
Maximum count for the semaphore object. This value must be greater than zero. The maximum count value is not set if the specified semaphore object already exists. |
sName | Name of the semaphore object. |
dcltrans transaction TMain constMAX_USERS := 25; var hSemaphore: number; begin hSemaphore := CreateSemaphore(NULL, MAX_USERS, MAX_USERS, "semaphore"); ... WaitForSingleObject(hSemaphore, INFINITE); // perform critical work ... ReleaseSemaphore(hSemaphore, 1); ... end TMain;