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 : Different services provided by DLR to

    Give details about the different services that are provided by DLR to CLR?

  • Q : Explain Cohesion Cohesion : The level

    Cohesion: The level to which a component executes a single well-stated task. A strongly cohesive technique, for example, will execute a single task, like adding an item to a data structure, or sorting several data, while a weakly cohesive technique wi

  • Q : Define Inconsistent state Inconsistent

    Inconsistent state: A state which an object must not be in. A class requires to be carefully designed in order to make sure that none of its examples can get into a conflicting state. An illustration of an inconsistent state may be a football team wit

  • Q : What is an Argument Argument : It is

    Argument: It is the information passed to a method. Arguments are as well sometimes termed as parameters. The method expecting to receive arguments should contain a formal argument declaration for each as portion of its method header. Whenever a metho

  • Q : What is Protected access Protected

    Protected access: Protected access is accessible to a class member prefixed with protected access modifier. This member is accessible to all classes stated within the enclosing package, and any sub-classes expanding the enclosing class.

  • Q : State the term multi threading State

    State the term multi threading.

  • Q : What are benefits of automated testing

    What are the benefits of automated testing over manual testing?

  • Q : Explain Relative filename Relative

    Relative filename: It is a filename whose full path is associative to some point within a file system tree-frequently the present working folder (that is, directory). For example:   

  • Q : Define the term Graphical User Interface

    Graphical User Interface: A Graphical User Interface (abbreviated as GUI) is a part of a program which permits user interaction through graphical components, like menus, buttons, text areas, and so forth. Interaction frequently includes the usage of a

  • Q : Explain the computer thread Explain the

    Explain the computer thread.

©TutorsGlobe All rights reserved 2022-2023.