Answered step by step
Verified Expert Solution
Question
1 Approved Answer
9. (10) A Barbershop consists of a waiting room with n chairs, and the barber room containing the barber chair. If there are no customers
9. (10) A Barbershop consists of a waiting room with n chairs, and the barber room containing the barber chair. If there are no customers to be served, the barber goes to sleep. If a customer enters the barbershop and all chairs are taken, then the customers wil leave the shop. If the barber is busy, but chairs are available, then the customer sits in one of the free chairs. If the barber is asleep, the customer wakes up the barber. Write pseudocode using semaphores to coordinate the barber and the customers. Define the following variables: shared int vacant_chairs-n; //represents vacant chairs in barber sho semaphore mutex=1; //handles m.e when clients access vacant-chairs semaphore barber-chair=1; //handles me. when clients access barber semaphore customer_in-0; //handles synch between barber and custome semaphore hair_cut_done 0; //handles synch between barber and custo Assume one barber thread and several customer threads. The barber thread is given below
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started