Networking, Distributed and Concurrent Programming

Homework Assignment : A Barbershop Problem Due: November 20, 2012 In this assignment, you are asked to write a multithreading problem to simulate the barbershop problem, which is a classical synchronization problem. The problem is taken from William Stallings's Operating Systems: Internals and Design Principles, 3rd Edition, 1998. Barber problem: Orchestrating activities in a barbershop 1. 3 chairs, 3 barbers, 1 cash register, waiting area includes 4 customers on a sofa, plus additional standing room for 7 customers. 2. A customer : • Will not enter the shop if it is filled to capacity • Takes a seat on the sofa, or stands if sofa is filled • When a barber is free, the customer waiting longest on sofa is served, the customer standing longest takes up seat on the sofa • When a customer's haircut is finished, any barber can accepted payment but because of the single cash register, only one payment is accepted at a time • Barbers divide their time between cutting hair, accepting payment and sleeping Assume the arrival rate of customers is 1 customer/3 minutes, the haircut speed of three barbers are the same 5 minutes. Initially, all three barbers are sleeping, and there is no guest in the barbershop. The output of your program is the snapshot of the barbershop at a given time (an input parameter of the program), including how many customers in the barbershop, how many are seated, how many are on the barber chairs, current status of three barbers, current status of cashier, and how many customers are dropped. Hints: • You can start from the code included in the slides, and try to solve the remaining problems (slides) step by step. • The interval of your simulation step should not larger than 1 minute. Extra credits: You can get 0.5 extra credit if you can handle the poisson arrival of customers. You can get 0.5 extra if you can handle varied hair cutting speed.

   Related Questions in Programming Languages

©TutorsGlobe All rights reserved 2022-2023.