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

• ##### Q :What does WSDL stand for What does WSDL

What does WSDL stand for?

• ##### Q :State the term DOM and how does this

State the term DOM and how does this relate to XML?

• ##### Q :What is applet? Explain life cycle of

Ans. Applet: An applet is an application designed to travel over the internet and to be executed on the client machine by a java compatible

• ##### Q :Define Package Package : The named

Package: The named grouping of classes and interfaces which gives a package namespace. Classes, interfaces and class members devoid of an explicit public, protected or private access modifier {access!modifier} encompass package visibility. The public

• ##### Q :Advantage of wrapping database calls in

What is the advantage of wrapping database calls in MTS transactions?

• ##### Q :Define BOOP Toolkit BOOP Toolkit : The

BOOP Toolkit: The BOOP Toolkit has been developed at the Institute for Software Technology at Graz University of Technology. It is based on the SLAM project and uses the same main concept of verification by abstraction and refinement to determin

• ##### Q :What is an Instruction set Instruction

Instruction set: The set of instructions which characterize a specific Central Processing Unit. The programs written in the instruction set of one type of CPU can’t usually be run on any other kind of CPU.

• ##### Q :Define the term Method signature Define

Define the term Method signature: This is the synonym for method header.

• ##### Q :Define the term Base case Define the

Define the term Base case: It is a non-recursive route via a recursive method.

• ##### Q :Determine a web page element which

How can I determine a web page element which contains exact text?