A synchronization tool called semaphore.Semaphores are variables that are used to signal the status of shared resources to processes.
Dijkstra (1965) suggested using an integer variable to count the number of wakeups saved for future use. In his proposal, a new variable type, called a semaphore, was introduced.
A semaphore is an integer variable that, apart from initialization, is accessed only through two standard atomic operations: (sleep) and (wakeup).
A semaphore could have the value 0, indicating that no wakeups were saved, or some positive value if one or more wakeups were pending.
Two operations, down and up (generalizations of sleep and wakeup, respectively);
The definition of is as follows:
wait (S) {
while S <= 0
;// no-op
S--;
}
The definition of is as follows:
signal (S) {
S++;
}
All the modifications to the integer value of the semaphore in the and operations must be executed indivisibly.
That is, when one process modifies the semaphore value, no other processcan simultaneously modify that same semaphore value.
In addition, in the case of , the testing of the integer value of (), and its possible modification (), must also be executed without interruption.