Concurrent Programming with Java
Lab Manual, Version 1.0, F. Astha Ekadiyanto,
2002.
|
Once you have managed to compile all the java codes, try to run the Applet. Try to generate a deadlock condition by reducing the Animation Speed scrollbar down to 0 (usually in the range of 100 ms would do so). In this case we just simply reduce the thinking and eating time so that all the philosophers will be busy accessing the forks. This will occasionally fall into the deadlock occurance when by chance all of the philosophers are starting to eat and holds their left and waiting for the right fork to be released by others. In many cases, finding out whether our code may lead to deadlock or not will not be so practical as this one. It is a software bug that is very difficult to detect. |
Here is the Challenge Lab. definition:
By now you will be able to detect that the code is not a deadlock free code.
Try to modify the code so that you can avoid the deadlock (mostly you would
just modify the Philosopher Class and/or the Fork Class)!
Hints:
This Challenge Lab. is a required Lab Task. You should submit them via email.