The goal of this assignment is to become knowledgeable with concurrent and distributed programming issues using the SALSA programming language.
A solution described by Hoare adds the requirement that at most n-1 philosophers are allowed to be seated at once. This ensures that at all times, at least one philosopher can eat, so there are no deadlocks. One way to implement this solution is to assume that there is a bouncer that does not allow a philosopher to sit if there are already n-1 philosophers sitting.
Algorithm for philosopher:
Loop forever { Make sure it is okay to sit (check with bouncer). Sit. Pick up the fork on the left. Pick up the fork on the right. Eat. Release the fork on the left. Release the fork on the right. Stand. Think. }When your program is run, it should be given the philosopher names (for n > 1 philosophers) as command line arguments and generate verbose output explaining what is happening, for example:
--> salsa Party Plato Socrates Aristotle Demosthenes Plato sits. Socrates sits. Aristotle sits. Socrates picks up the left fork. Socrates picks up the right fork. Plato picks up the left fork. Socrates eats. Socrates releases the left fork. Socrates releases the right fork. Aristotle picks up the left fork. Socrates stands up. Demosthenes sits. Socrates thinks. Plato picks up the right fork. ...
softFailure() Don't allow any other philosophers to enter the lounge. For each philosopher p in the room Tell p to leave. After all have left, allow philosophers to enter again.
hardFailure() Don't allow any other philosophers to enter the lounge. For each philosopher p in the room Kill p. After all have been killed, allow philosophers to enter again.The bouncer should then check periodically if all philosophers are still alive (using a heart-beating protocol). If not, he/she should generate new philosophers so that there are always n philosophers in the system.
You may also want to give a time argument to these failures, so that the failure (or time-bomb) does not happen until that time has elapsed.
Due Date:
Received Time | Grade Modification |
before Monday, May 2, 11:59PM | +10% |
before Tuesday, May 3rd, 11:59PM | no modification (on time) |
before Wednesday, May 4th, 11:59PM | -10% |
from Thursday, May 5th, 12:00AM to
Friday, May 6th, 11:59PM |
-25% |
after Saturday, May 7th, 12:00AM | not accepted |
Grading: The programs will be tested on the CS network version of SALSA. The assignment will be graded mostly on correctness, but code clarity / readability will also be a factor (comment, comment, comment!). See the professor or TAs, if you have ideas for other extensions for this assignment and would like extra credit for implementing them.
Submission Requirements: Please submit a ZIP file with your code, including a README file. In the README file, place the names of each group member (up to two). The README should also clearly describe how to compile and run the code, as well as explaining your architecture and any design decisions made. Your code will be tested on the CS machines, so make sure it works there. Your ZIP file should be named with your WebCT user name(s) as the filename, either userid1.zip or userid1_userid2.zip. Only submit one assignment per pair via WebCT.