Engr 664: Concurrent Programming
Fall Semester 1997

Assignment #5
Due 9:30 A.M. Tuesday, 2 December


Problem: Late Evening Study Session

A group of M computer science graduate students is studying late one evening at a professor's house. The students are drinking iced tea from a large pitcher that holds N glasses of tea. The professor, who had stayed up late the night before preparing another one of his brilliant lectures, is napping in a chair. When a student wants to drink, he or she fills a glass from the pitcher, unless it is empty. If the pitcher is empty, the student (gently) awakens the professor and then waits for the professor to return with a full pitcher from the kitchen. The behaviors of the students and the professor are specified by the following threads.

Student:

    while (true) 
        {   tellProfIfPitcherEmpty(); 
            fillGlassFromPitcher(); 
            drinkAndStudy();
        }

Professor:

    while (true) 
        {   waitForPitcherToEmpty();
	    getNewPitcherOfNServings();
        }

Develop a Java program that simulates the above actions of the students and professor. You may use either monitors or semaphores for the thread synchronization. (Do not use a busy-waiting solution.) Your program should avoid deadlock and awaken the professor only when the pitcher is empty. Is your solution starvation-free?

Document and test your program appropriately.


Assignment Submission

Submit a paper copy of your program listing and testing output to your instructor by the due date. Make sure you have documented your program appropriately and tested your program thoroughly.

Also submit copies of your source code via email to en664@hal.cs.olemiss.edu.


UP to the ENGR 664 Assignments document?


Copyright © 1997, H. Conrad Cunningham
Last modified: 10 November 1997.