--%>

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 : Libraries involved in Windows

    Explain the important libraries involved in Windows programming?

  • Q : Define the term Host system Define the

    Define the term Host system: It is a computer system on which a process is executed or run.

  • Q : Describe Multiple-boot options

    Multiple-boot options: The hardware configurations of several computers are capable to run various operating system and window manager combinations. A few systems permit a user to select which combination they wish to utilize during a specific session

  • Q : Explain Java PathFinder Java

    Java PathFinder: Java PathFinder (JPF) is a model checker that has been developed as a verification and testing environment for Java programs (Figure shown below). It is available as open source at SourceForge.net (JPF website). It consists of a custo

  • Q : Explain Upcast Upcast: It is a cast

    Upcast: It is a cast towards an object's ultimate super type - which is, `up' the inheritance hierarchy towards the Object class, for example:         // Upcast from VariableContr

  • Q : Define Stream class Stream class : An

    Stream class: An input stream class is one which delivers data from its source (frequently the file system as a series of bytes. Likewise, an output stream class will write byte-level data. The stream classes must be contrasted with the operation of r

  • Q : Define Java virtual machine or JVM

    Define Java virtual machine (JVM): A Java Virtual Machine (JVM) is an abstract computing machine, or virtual machine (set of computer software programs and data structures) which is a platform-independent execution environment that converts Java bytec

  • Q : Explain the way to enter element content

    Explain the way to enter element content.

  • Q : Define the term Catching exceptions

    Catching exceptions: Exceptions are caught in the catch clause of the try statement. Catching an exception provides the program a chance to recover from the trouble or attempt a repair for whatsoever caused it.

  • Q : Explain Look-and-feel Look-and-feel :

    Look-and-feel: The visual impression and interaction style given by a user interface. This is mainly the responsibility of the window manager (that is, in collaboration with the fundamental operating system) running on a specific computer. This refers