A semaphore is a synchronisation construct allowing processes to coordinate access to shared resources without busy waiting. An integer-valued variable accessed only through two atomic operations: wait () and signal ().
Data Structure
Implementation
typedef struct { int value; queue process_queue;} semaphore;
Value can be any non-negative integer, representing available resource instances. See Counting Semaphore.
M-Semaphores
Allow atomic waiting on multiple semaphores simultaneously. Process proceeds only if all, preventing partial resource acquisition and helping avoid deadlocks.