Explain a binary semaphore with the help of an example?
An abstract data type (ADT) is a semaphore which defines a nonnegative integer variable that apart from initialization is accessed only by two standard operations i.e.: wait and signal. The typical definition of wait in pseudo code is given as
wait(S){
while(S<=0)
; // not do anything
S--;
}
The classical definitions of signal in pseudocode is signal(S){
S++;
}
A binary semaphore is one which only gets the values 0 and 1. Such semaphores are utilized to implement mutual exclusion.