The SEM
feature provides semaphore synchronization objects. A semaphore is an integer counter and an associated thread wait queue. When initialized, the semaphore counter receives a user-defined positive or null value.
Two main atomic operations are available on semaphores: P (or pass) and V (or free).
The counter is decremented when a thread performs a P on a semaphore. If the counter reaches a negative value, the thread is blocked and put in the semaphore's queue, otherwise, the thread continues its execution normally.
The counter is incremented when a thread performs a V on a semaphore. If the counter is still lower than or equal to zero, one of the threads queued in the semaphore queue is picked up and awakened.
Semaphores are data structures allocated in the actors' address spaces. No kernel data structure is allocated for these objects. They are simply designated by the address of the structures. The number of these types of objects that threads may use is therefore unlimited.
For more details, see SEM(5FEA).