The Dining Philosophers (cont.)
Array [1..5] of semaphores : fork = [1, 1, 1, 1, 1 ];
Philosopher Pi:
Repeat
think;
wait( fork[i] );
wait( fork[ (i+1) mod 5 );
eat;
signal( fork[ (i+1) mod 5 );
signal( fork[i] );
Forever
Well, what do you eat?
… sorry, …, think?
Previous slide
Next slide
Back to first slide
View graphic version