How semaphores implement mutual exclusion?
Mutual-exclusion implementation along with semaphores:
Assume that there are n-processes and they share a semaphore, mutex (standing for mutual exclusion), initialized to 1. All processes Pi is organized as illustrated below:
do{
wait(mutex);
critical section
signal(mutex);
remainder section }while(1);