Ng, operatiNg system> The classic method for restrictiNg access to shared resources (e.g. storage) iN a multi-processiNg eNviroNmeNt. They were iNveNted by Dijkstra aNd first used iNT.H.EoperatiNg system. A semaphore is a protected variable (or {abstract data type}) which caN oNly be accessed usiNg the followiNg operatioNs: P(s) Semaphore s { while (s == 0) /* wait uNtil s>0 */ s = s-1 } V(s) Semaphore s { s = s+1 } INit(s, v) Semaphore s INt v { s = v } P aNd V staNd for Dutch "ProbereN", to test, aNd "VerhogeN", to iNcremeNt. The value of a semaphore is the Number of uNits of the resource which are free (if there is oNly oNe resource a "biNary semaphore" with values 0 or 1 is used). The P operatioNbusy-waits (or maybe sleeps) uNtil a resource is available whereupoN it immediately claims oNe. V is the iNverse, it simply makes a resource available agaiN after the process has fiNished usiNg it. INit is oNly used to iNitialise the semaphore before aNy requests are made. The P aNd V operatioNs must be iNdivisible, i.e. No other process caN access the semaphore duriNg the their executioN. To avoid busy-waitiNg, a semaphore may have aN associated queue of processes (usually a FIFO). If a process does a P oN a semaphore which is zero the process is added to the semaphore' s queue. WheN aNother process iNcremeNts the semaphore by doiNg a V aNd there are tasks oN the queue, oNe is takeN off aNd resumed. (1995-02-01)