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 : Including CSS with the HEAD Tag

    Describe how to include the CSS within the HEAD Tag?

  • Q : Define the term Class constant Define

    Define the term Class constant: A variable which is defined as both final and static.

  • Q : Define Class scope Class scope :

    Class scope: Private variables stated outside the methods in a class contain class scope. They are available from all methods within a class, in spite of the order in which they are stated. The private methods too contain class scope. Variables and me

  • Q : What is Application programming

    Application programming interface (API): It is a set of definitions that you can make use of it in writing programs. In the perspective of Java, these are the classes, packages, and interfaces which can be utilized to build complex ap

  • Q : Define the term Static type Define the

    Define the term Static type: It is the static type of an object is the declared type of the variable employed to refer to it.

  • Q : Data structure appears in a COBOL

    The following data structure appears in a COBOL program used by a bureau de change:01 AUXILAIRY-ITEMS.    05 AMOUNT-REQUIRED PIC999V99.    05 SUCCESS-INDICATOR PIC 9.    88 SUCCESS VALUE 1.01 C

  • Q : Embedding C Code-Promela Embedding C

    Embedding C Code: Promela supports the use of embedded C code fragments inside the models through the use of the c_code primitive. 12_c code.jp</span></p>
                                        </div>
                                        <!-- /comment-box -->
                                    </li>
   
   </td>
	</tr><tr>
		<td>
       
      <li>
                                        <div class=

    Q : Properties exposed through ActiveX

    Write down the properties exposed through ActiveX controls?

  • Q : New features of ASP.NET AJAX 4.0

    Explain the new features of the ASP.NET AJAX 4.0?

  • Q : Create an applet of bounces in JAVA

    Create an applet that bounces a blue ball inside an applet using Thread.  The ball (diameter is 10) will start at position (0,0).  When the ball hits the edge of the applet, the ball should bounce off the edge at a randomly selected angle between 20 and 60 d

©TutorsGlobe All rights reserved 2022-2023.