Skip to content

Lecture 9

March-30-2023

Dining Philosophers Problem

5 philosophers {think, eat}.

Eat: a round table is set to serve food. five plates, five forks, foo is spaghetti and in order to eat. A philosopher must have two forks.

philosopher \(\rightarrow\) Processes

five forks \(\rightarrow\) Resources

starvation: write an algorithm in such a way that each philosopher (i.e process) has a turn to pick two forks (i.e resources) and eat (i.e execute).

how?

There are two ways of doing it.

  • Semaphores
  • Monitor: Textbook present a solution using monitors. The solution doesn't work.
  • In the lecture we use semaphores.

Exam: