Concurrent Programming 8893
Assignment 3

Due: Tuesday, March 16 at 08:55.
  1. (Text 5.6 p. 256 (b) only) Dining Philosophers One solution to the dining philosophers problem, in which the philosophers are modeled as in and eat with chopsticks as in, is to use a waiter to control access to the chopsticks. Each phiolosopher will request permission to eat before trying to pick up his chopsticks, and will inform the waiter when he is finished eating.

    You are to implement the assign3_Waiter class as a monitor, with public methods as follows:

    Be sure to specify the monitor invariant in comments in your code. Your solution should avoid starvation without relying on the fairness of the monitor locks. Submit Don't include main -- I'll make my own.

  2. For their post-graduation party a group of students wish to share a seemingly endless, but possibly slow arriving, supply of beer. They hire a runner to fetch the beer (in kegs) and a bartender to ensure that it is dispensed in an orderly fashion. When a student is ready for a new glass of beer, she will approach the bartender, and, if there is some in the keg, he will pour it for her. If the keg is empty she will wait until it is replaced with a full keg. The runner fetches kegs one at a time and, when he arrives back at the bar, he signals the bartender that he is ready. When the current keg is empty the bartender allows the runner to install the new keg. The runner then leaves to fetch a new keg, and the bartender continues to serve students.

    The students drink at varying rates, so, in the interest of fairness, they instruct the bartender to keep track of the number of glasses of beer served to each student, and, when more than one student is waiting to be served, to serve the student who has had the fewest glasses.

    The more astute among the students (i.e., those who have taken concurrent programming), recognize this as a conditional synchronization problem and set out to simulate the interaction in a Java program. They model the students and runner as in, and

    Implement the assign3_Bartender class using Java monitors. The class must have public methods as follows:

    Be sure to specify the monitor invariant in comments in your code. Submit Don't include a main -- I'll put yours and mine together to make my own party.

Back to 8893 homepage

Last modified: Tue 2004.03.09 at 08:57 NST by Dennis Peters