Use the SEMAPHORE data type to create semaphore variables, which are used in concurrent scripts to mutually exclude competing threads or control access to a resource.
Values of type SEMAPHORE can only be assigned a value once. The value must be an INTEGER greater than zero. Once it is set, your code can get the semaphore's value, but cannot set it.
When you allocate a semaphore variable, you must initialize it before you can invoke Acquire. For example, the following statement creates a binary semaphore that allows you to control access to a single resource.
SEMAPHORE semAlpha = 1
Use a semaphore to control the access of competing threads to a resource as follows:
Before using a semaphore-protected resource of any description, invoke Acquire (semA), where semA is the semaphore assigned to this resource.
When you have completed use of the resource protected by semA, invoke Release (semA) to make the semaphore, and therefore the resource, available to another thread.