I have been posed a question by my lecturer and I'm trying to figure the right way to go about it. They want me to ensure mutual exclusion for n processes. The code provided is as follows:Process Pi    while(true){            while(#taken == 5){}            #taken := #taken+1;            // enjoy a non-alcoholic drink //            #taken := #taken-1;                 }    }The task provided is Add synchronization code such that the requirements for the barare enforced. i.e. only five people at the bar at a time. Assuming n processes how can I make sure that only one process can enter the critical section at a time? I've tried this:s = 1Process Pi    while(true){        if(s > 0){            while(#taken == 5){}            #taken := #taken+1;            // enjoy a non-alcoholic drink //            #taken := #taken-1;            s=s-1            }        }    }But it doesn't appear to me mutually exclusive. They also said this in a study group this evening:You may also assume the existence of mutual exclusion variables that support the operations preprotocol(mutex) and postprotocol(mutex) to create critical sections.I don't really understand what this means. Would anyone be able to shed any light on this issue?
Concurrent Programming Bar Problem
algorithms;concurrency;mutual exclusion