This page is accessible at www.se.rit.edu/~se441/Assignments/CigaretteSmokers.html.
This activity will be done Individually.
This politically incorrect problem was originally proposed by Parnas in 1975.
Assume that smoking a cigarette requires three items:
Assume further that there are three chain smokers seated around a table. Each smoker has an infinite supply of one of the necessary ingredients and no two smokers have the same ingredient. There is a fourth person at the table, an arbiter who has an infinite supply of each of the three ingredients available. Every so often the arbiter selects two of the three ingredients at random, places these on the table, and notifies all smokers that materials are available. The one smoker for whom the two ingredients complete his needs takes the ingredients, smokes a cigarette, and returns to wait for the materials to be placed on the table again. The two other smokers, recognizing that the materials do not meet their requirements, simply wait for the next round of materials to be provided.
You are to solve this problem using UntypedActors. Your solution must have actors for at least the three smokers and the arbiter; you are free to add other actors if it makes the solution simpler. Your static void main( ... ) method must be in a class named Main; I will compile all your Java source files and execute the program as follows:
java Main nRounds
Where nRounds
is the number of times the arbiter places materials on the table; after
this limit is reached, the program must terminate gracefully (i.e., no
abrupt termination of actors that are still doing work).
Submit a zip archive (and only a zip archive) named smokers.zip to the 07_Activity dropbox by the due date. The archive will contain Main.java and any other java source files used in your solution. All source files must be in the default package. In addition, there will be a text file, readme.txt, which discusses (a) your approach to the solution, (b) the key elements of your design, and (c) any issues you encountered in creating the solution; this is also the place to cite any resources you used in solving the problem.
DO NOT include subdirectories or irrelevant files!
Of the 10 points available for this activity,