Download presentation
Presentation is loading. Please wait.
Published byAlban Walters Modified over 6 years ago
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.
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.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.