What are semaphores?
Semaphore: A semaphore is a synchronization tool which gives a general-purpose solution to controlling access to critical sections. It s an abstract data type (ADT) which defines a nonnegative integer variable that, apart from initialization, is accessed simply through two standard operations that are: wait and signal. The typical definition of wait in pseudo code is
wait(S){
while(S<=0)
// do nothing
S--; }
The classical definitions of signal in pseudo code is signal(S){
S++; }
While one process modifies the semaphore value, anno one process can concurrently modify that similar semaphore value. As well, in the case of the wait(S), the testing of the integer value of S (i.e. S<=0), and its possible modification(S--), should also be executed without interruption.