Question: Write an analysis for this solution to the Barber problem Does it work? Are there any issues with the solution? Is it efficient? Support your
Write an analysis for this solution to the Barber problem Does it work? Are there any issues with the solution? Is it efficient? Support your answers with example:
customer(){ while(TRUE) { customer= nextcustomer(); p(mutex) if(emptyBarberChair < 0) {V(mutex); continue;} V(mutex); P(chair); p(mutex); emptyBarberChair--; sitInChair(customer); V(mutex); V(waitingCustomer); } } theBarber (){ semaphore mutex =1; semaphore chair =N; semaphore waitingCustomer =0; int emptyBarberChairs = N; while (TRUE) { P(waitingCustomer); P(mutex); emptyBarberChair++; customer = acceptCustomer(); V(mutex); V(chair); } fork(customer,0); fork(barber,0); } Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
