Problem

A number of problems remain with the fair barbershop of Figure A.6. Modify the program to...

A number of problems remain with the fair barbershop of Figure A.6. Modify the program to correct the following problems.

a. The cashier may accept pay from one customer and release another if two or more are waiting to pay. Fortunately, once a customer presents payment, there is no way for him to un-present it, so in the end, the right amount of money ends up in the cash register. Nevertheless, it is desirable to release the right customer as soon as his payment is taken.

b. The semaphore leave_b_chair supposedly prevents multiple access to a single barber chair. Unfortunately, this semaphore does not succeed in all cases. For example, suppose that all three barbers have finished cutting hair and are blocked at semWait(leave_b_chair). Two of the customers are in an interrupted state just prior to leave barber chair. The third customer leaves his chair and executes semSignal (leave_b_chair). Which barber is released? Because the leave_b_chair queue is first in first out, the first barber that was blocked is released. Is that the barber that was cutting the signaling customer’s hair? Maybe, but maybe not. If not, then a new customer will come along and sit on the lap of a customer that was just about to get up.

c. The program requires a customer first sits on the sofa even if a barber chair is empty. Granted, this is a rather minor problem, and fixing it makes code that is already a bit messy even messier. Nevertheless, give it a try.

Figure A.6 A Fair Barbershop

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter A