A barber shop has a barber,a barber chair and a waiting room with 5 chairs.When a barber finishes cutting a customer's hair ,the barber fetches another customer from the waiting room if there is a customer ,or stands by the barber chair and daydreams,if the waiting room is empty.A customer who needs a haircut enters the waiting room.If the waiting room is full ,the customer goes away and comes back later.If the barber is busy but there is a waiting room chair available,the customer takes a seat. If the waiting room is empty and the barber is daydreaming the customer sits in the barber chair and wakes the barber up. Think of the barber and customer as processes bwhich should be synchronized.You are required to write the code for the barber process and the customer rocess using semaphores.Your answer should first(I) list(in English sentences) what synchronization and/or critical section problem you have to solve,(ii) define what semphores you have to use(including initial value)and (iii) then write the pseudo code of the two processes.you can assume the wait and signal are available as primitive calls on a semaphore with their usual meanings.
A barber shop has a barber,a barber chair and a waiting room with 5 chairs.When a barber finishes cutting a customer's hair ,the barber fetches another customer from the waiting room if there is a customer ,or stands by the barber chair and daydreams,if the waiting room is empty.A customer who needs a haircut enters the waiting room.If the waiting room is full ,the customer goes away and comes back later.If the barber is busy but there is a waiting room chair available,the customer takes a seat. If the waiting room is empty and the barber is daydreaming the customer sits in the barber chair and wakes the barber up.
Think of the barber and customer as processes bwhich should be synchronized.You are required to write the code for the barber process and the customer rocess using semaphores.Your answer should first(I) list(in English sentences) what synchronization and/or critical section problem you have to solve,(ii) define what semphores you have to use(including initial value)and (iii) then write the pseudo code of the two processes.you can assume the wait and signal are available as primitive calls on a semaphore with their usual meanings.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps