The Dining Philosopher solution using monitors shown in the code snippet below does not suffer from deadlock. However, starvation is still possible. Explain in details why. Each philosopher i invokes the operations pickup() and putdown() in the following sequence: DiningPhilosophers.pickup(i);                    EAT DiningPhilosophers.putdown(i);

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter19: Probabilistic Dynamic Programming
Section19.4: Further Examples Of Probabilistic Dynamic Programming Formulations
Problem 7P
icon
Related questions
Question

The Dining Philosopher solution using monitors shown in the code snippet below does not suffer from deadlock. However, starvation is still possible. Explain in details why. Each philosopher i invokes the operations pickup() and putdown() in the following sequence:

DiningPhilosophers.pickup(i);

                   EAT

DiningPhilosophers.putdown(i);

monitor DiningPhilosophers
{
enum i THINKING; HUNGRY, EATING) state [5] ;
condition self [51:
void pickup (int i) {
www
state[i]
test (i):
if (state[il != EATING) self[i].wait;
= HUNGRY;
}
void putdown (int i) {
state[i] = IHINKING;
%3D
// test left and right neighbors
test((i + 4) % 5);
test ((i + 1) % 5);
void test (int i) {
if ((state[(i + 4) % 5] != EATING) &&
(state[i]
(state[(i + 1) % 5] != EATING) ) {
state[i] = EATING ;
self[il.signal () ;
}
HUNGRY) &&
%3D
initialization code() {
for (int i = 0; i < 5; į++)
state[i]
-1ΗINKING ,
Transcribed Image Text:monitor DiningPhilosophers { enum i THINKING; HUNGRY, EATING) state [5] ; condition self [51: void pickup (int i) { www state[i] test (i): if (state[il != EATING) self[i].wait; = HUNGRY; } void putdown (int i) { state[i] = IHINKING; %3D // test left and right neighbors test((i + 4) % 5); test ((i + 1) % 5); void test (int i) { if ((state[(i + 4) % 5] != EATING) && (state[i] (state[(i + 1) % 5] != EATING) ) { state[i] = EATING ; self[il.signal () ; } HUNGRY) && %3D initialization code() { for (int i = 0; i < 5; į++) state[i] -1ΗINKING ,
Expert Solution
steps

Step by step

Solved in 5 steps

Blurred answer
Knowledge Booster
Hash Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole