Please make sure that you're using the same edition of the book. There is no guarantee that older editions use the same numbering for problems. Please submit a single tar file.
Also, identify the queueing model for this system in Kendall's notation.
takeForks(philNumber)
, where
philNumber
identifies the number of the philosopher wishing
to eat. When a philosopher finishes eating, it invokes
returnForks(philNumber)
. Your solution will implement the
following interface:
public interface DiningServer { // called by a philosopher when it wishes to eat public void takeForks(int philNumber); // called by a philosopher when it is finished eating public void returnForks(int philNumber); }
The implementation of the interface follows the outline of the solution provided in Figure 6.25. Use Java's condition variables to synchronize activity of the philosophers and prevent deadlock.
Note: If you prefer, you can also implement this in C uses pthreads.
Process | Allocation | Max | Available |
A B C D | A B C D | A B C D | |
P0 | 2 1 0 0 | 2 1 0 0 | 0 2 5 1 |
P1 | 0 0 0 1 | 0 5 7 1 | |
P2 | 4 5 3 1 | 6 5 3 2 | |
P3 | 2 3 6 0 | 2 5 6 0 | |
P4 | 4 1 0 0 | 6 5 6 3 |
Answer the following questions using the banker's algorithm: