EEL 358 -
Operating Systems
Fall 2006
Indian Institute of
Technology Delhi, New Delhi
Assignment 4
Synchronization using Pthreads
The objective of this assignment is to let you gain some hands on experience in common concurrent program design and implementation.Scenario
There is Barber Shop with multiple Barber¡¦s. You can use any numbers of Barbers minimum is 3.The customers coming for service are served in First-Come-First-Serve basis.
Arrival Rate
Customer Arrival Rate is such that, one barber is always awake serving the customer, i.e., all the Barbers cannot go to sleep at a time.
So if Nq + Ns = = 1 => generate more customers.
And if Nq + Ns >1 => You can decide to generate more customers or not.
where Nq and Ns are the number of customers in the queue and getting served respectively.
Dispatcher
Dispatcher is the one who guides the incoming customer to the sleeping barber¡¦s.
Implementation
Customers:
Can be data-structures containing information about its
1. Service time
2. Arrival time
3. Status
a. Served
b. Waiting
c. Terminated
Barber
Is thread with thread-id and status
Status
1. Sleeping ¡§if no customers¡¨
2. Serving ¡§if customers are waiting to be served¡¨
Customer generator
It is a thread, which decides whether to generate more customers, or not. It also decides the service time customer needs. The customer¡¦s service time is randomly generated.
Dispatcher:
It is a thread, which dispatches the customer to the sleeping barber. The dispatching is done in round robin fashion to avoid starvation.
If more customers are there it should put in the queue. Start initially with random customers generated and the entire barber¡¦s are sleeping. You can use any type of signaling between the threads for synchronization.
Log file Generation
Generate a log file which has the all the information about the system at any particular instant of time like number of customers in the queue, number of customers getting service, number of sleeping barbers and what are their ids. The Log file is generated by an extra thread which is automatically triggered as the log time interval expires. The thread after writing log file returns the control to the system.
Sample Output
¡@
¡@
¡@
¡@
¡@
¡@
¡@
¡@
¡@
Marks Distribution
¡@
¡@
¡@
¡@
¡@
¡@
¡@
Submission
Please submit a tar file on-line containing the following:
- README file with
a.
It should contain the login ID of the user.b. How the program executes
c. Implementation Details
d. Explanation of synchronization and algorithm implementation.
The code which implements the solution to the given synchronization problem. The tar file can be uploaded in the assignment # 4 using this link. Please make sure that you upload the assignment only once. In case of multiple submission ONLY first submission will be used for grading.
Deadline
The submission deadline for the assignment # 4 is November 7, 2006 [23:59 Hrs].
Questions
If you have any further questions relating to this assignment, you may contact the TA, Mr. Shashwat Agrawal [Mob - 9910762332].