Question: In the dining-philosopher problem, assume that the shared data are semaphore chopstick [4]; where all the elements of chopstick are initialized to 1. The structure
In the dining-philosopher problem, assume that the shared data are
semaphore chopstick [4];
where all the elements of chopstick are initialized to 1. The structure of philosopher i is shown as follows:
void philosopher (int i) { while (TRUE) { wait (chopstick[i]; wait (chopstick[i+1] % 5); ... eat (); ... signal (chopstick[i]; signal (chopstick[I+1] % 5); ... think (); ... } }
(1)Why do we reject the above program codes to solve the dining-philosophers problem?
(2)Please use Monitor to solve the problem.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
