El Problema de los Filósosofos Comensales / The Dining Philosophers Problem

The Dining Philosophers problem was formulated by Edsger Djisktra in 1965 to illustrate the kind of issues we can find when multiple processes compete to gain access to exclusive resources.

The Dining Philosophers problem was formulated by Edsger Djisktra in 1965 to illustrate the kind of issues we can find when multiple processes compete to gain access to exclusive resources.

In this problem, five philosophers meet to have dinner.

They sit at a round table and each one has a bowl of rice in front of them.

There are also five chopsticks, one between each philosopher.

The philosophers spent their time thinking about The Meaning of Life.

Whenever they get hungry, they try to eat.

But a philosopher needs a chopstick in each hand in order to grab the rice.

If any other philosopher has already taken one of those chopsticks, the hungry philosopher will wait until that chopstick is available.

This problem is interesting because if it is not properly solved it can easily lead to deadlock issues:

  1. A gentle introduction to actor-based concurrency.

  2. Source code from this article. All of the code from this article is in Practicing Ruby's example repository, but the links below highlight the main points of interest:

  3. Scaling Ruby with Actors, or How I Learned to Stop Worrying and Love Threads by Mike Perham Rubyconf 2011

Casiano Rodriguez León 2015-06-18