A semaphore is a synchronisation construct allowing processes to coordinate access to shared resources without busy waiting. An integer-valued variable S accessed only through two atomic operations: wait (P) and signal (V).
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 allSi>0, preventing partial resource acquisition and helping avoid deadlocks.