Presentation is loading. Please wait.

Presentation is loading. Please wait.

Barbershop Example We can simulate a barbershop using semaphores.

Similar presentations


Presentation on theme: "Barbershop Example We can simulate a barbershop using semaphores."— Presentation transcript:

1 Barbershop Example We can simulate a barbershop using semaphores.
The barbershop has three chairs, three barbers, a waiting room for up to 20 customers, and 4 of these waiting customers may sit on the couch. Note that the Barbershop example is in Appendix A of the textbook.

2

3 Problem There is a problem with this barbershop.
In a real barbershop, if three customers in a row are seated for a haircut, the haircuts will not necessarily be completed in that order (one customer may not have much hair to cut). However, our code will cause the first customer seated to leave and pay as soon as any haircut is finished. A solution uses a separate semaphore for each customer.

4


Download ppt "Barbershop Example We can simulate a barbershop using semaphores."

Similar presentations


Ads by Google