The semaphore constructor sets waiters empty and value to a supplied non-negative integer. All semaphore operations are atomic. Suppose S.value is initially 1. At most one such block of code can be in execution at any one time. Suppose C.value is initially 0.
Semaphores have their dangers.
Several higher-level facilities have been supplied to make synchronization safer. The statements safely execute in mutual exclusion of any other statements locked by any of the listed mutexes. A monitor consists of shared variables, and a collection of user-defined operations on them. The language ensures that at most one of the operations is in execution at any time. Use of monitors is fairly easy.