Description
A semaphore is a confined variable whose value can be accessed and changed only by the operations P and V and initialization operation known as ''Semaphoiinitislize''.
• Binary Semaphores can take for granted only the value 0 or the value 1 counting semaphores also described general semaphores can suppose only nonnegative values.
• The P (or wait or sleep or down) operation on semaphores S, assumed as P(S) or wait (S), controls as follows:
• P(S):
IF S > 0
THEN S := S - 1
ELSE (wait on S)
The V (or signal or wakeup or up) process on semaphore S, written as V(S) or signal (S), controls as follows:
V(S): IF (one or additional process are waiting on S)
THEN (let one of these processes proceed)
ELSE S := S +1