edited by
494 views
4 votes
4 votes

Consider the following solution to the classical Dining Philosophers Problem using Semaphores, where $5$ philosophers in a dining table are trying to eat using $5$ chopsticks each one placed to the right and left of each philosopher.
semaphores chopstick $[0\dots 4]$ all initialized to $1.$

repeat
wait(chopstick[i+(i%2)]);
wait(chopstick[(i+1-(i%2)) mod 5]);
. . .
eat
. . .
signal(chopstick[i]);
signal(chopstick[(i+1) mod 5]);
. . .
think
. . .
until false;


Which of the following properties are satisfied by the above solution? (Mark all the appropriate choices)

  1. Starvation freedom
  2. Deadlock freedom
  3. Mutual Exclusion
  4. Progress
edited by

1 Answer

Best answer
5 votes
5 votes
Here, the odd numbered philosopher is picking the right side chopstick first and the even numbered philosopher is picking the left side chopstick first. In this way maximum $4$ philosophers can pick the chopstick at any time and this avoids the possibility of a deadlock as in the classical dining philosopher problem solution where all $5$ of them can pick the left side chopsticks or the right side chopsticks. Since there is no deadlock, there is progress as well.

Since wait is used on each chopstick, mutual exclusion is satisfied.

Starvation freedom is not guaranteed as any one of the philosopher can not get the chopstick for an infinite time (it can be picked by the neighboring philosopher.

Correct answer: B;C;D.
selected by
Answer:

Related questions

3 votes
3 votes
1 answer
4