Please trace the execution of the following solution to the Dining Philosopher problem. #define enum status (EATING, HUNGRY, THINKING}; monitor diningPhilosophers { status state[N]; condition self[N];...


Please trace the execution of the following solution to the Dining Philosopher problem.<br>#define<br>enum status (EATING, HUNGRY, THINKING};<br>monitor diningPhilosophers {<br>status state[N];<br>condition self[N];<br>test (int i) {<br>if( (state[ (i-1) mod N]<br>!= EATING) &&<br>(state[i]<br>HUNGRY) &&<br>==<br>(state[(i+l) mod N] != EATING)) {<br>= EATING;<br>state[i]<br>self[i].signal ();<br>}<br>} ;<br>public:<br>diningPhilosophers () { // Initilization<br>for (int i<br>= 0; i < N; i++) state[i]<br>ΤHINKING ;<br>} ;<br>test(int i) {<br>if ( (state[ (i-1) mod N] != EATING) &&<br>(state [i]<br>(state [ (i+1) mod N] != EATING)) {<br>state[i]<br>self[i].signal();<br>} ;<br>} ;<br>public:<br>diningPhilosophers () {...} ;<br>pickUpForks (int i)<br>state[i]<br>test (i);<br>if(state [i]<br>HUNGRY) &&<br>=3=<br>EATING;<br>HUNGRY;<br>!= EATING) self[i].wait ();<br>} ;<br>putDownForks (int i) {<br>state [i]<br>test ( (i-1) mod N);<br>test ((i+1) mod N);<br>} ;<br>= THINKING;<br>Onerating Suatems: A Modern Derenective Chanter 0<br>

Extracted text: Please trace the execution of the following solution to the Dining Philosopher problem. #define enum status (EATING, HUNGRY, THINKING}; monitor diningPhilosophers { status state[N]; condition self[N]; test (int i) { if( (state[ (i-1) mod N] != EATING) && (state[i] HUNGRY) && == (state[(i+l) mod N] != EATING)) { = EATING; state[i] self[i].signal (); } } ; public: diningPhilosophers () { // Initilization for (int i = 0; i < n;="" i++)="" state[i]="" τhinking="" ;="" }="" ;="" test(int="" i)="" {="" if="" (="" (state[="" (i-1)="" mod="" n]="" !="EATING)" &&="" (state="" [i]="" (state="" [="" (i+1)="" mod="" n]="" !="EATING))" {="" state[i]="" self[i].signal();="" }="" ;="" }="" ;="" public:="" diningphilosophers="" ()="" {...}="" ;="" pickupforks="" (int="" i)="" state[i]="" test="" (i);="" if(state="" [i]="" hungry)="" &&="3=" eating;="" hungry;="" !="EATING)" self[i].wait="" ();="" }="" ;="" putdownforks="" (int="" i)="" {="" state="" [i]="" test="" (="" (i-1)="" mod="" n);="" test="" ((i+1)="" mod="" n);="" }="" ;="THINKING;" onerating="" suatems:="" a="" modern="" derenective="" chanter="">

Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here