Dining Philosophers Problem

Published by admin, on Feb 15 2009, in the categories: Uncategorized

The dining philosophers problem  is a computer problem. It is practically a problem that is raised when more people meet. This problem makes you think at synchronization and multi-process. This problem was invented by E. W. Dijkstra and it`s about five philosophers that are sitting at a round table doing two things : eating or thinking. They can`t do the same things at once so, while they eat they can`t think and while they think they don`t eat. They all sit at a table with plates of spaghetti for each one. Each plate has a fork meaning that each philosopher has one fork. Taking things logically every philosopher has a fork in his right and one in his left. Because eating spaghetti is difficult with only one fork, they have to eat with two forks. If one philosopher eats with two forks automatically the other one can`t eat. Another way this problem can be illustrated is by replacing the spaghetti with rise and the forks with chop sticks to show more clearly that you can`t eat the rise with one chopstick you need two.



During this entire scene, the five philosophers don`t talk to each other. This situation can create a deadlock as they say meaning that every one of the philosophers has a felt fork and is waiting for a right one. The hole idea of the dining philosophers problem is that while they continuously wait for the right fork , they also get hungry. When one picks up the two forks or chopstick he starts eating. After a while he puts the chopsticks down and starts thinking. This is a tricky problems that makes people think. Because it`s played with philosophers it makes it more interesting. The most simple solution to this situation is bringing a waiter to assist them. The philosophers can ask the waiter when they can pick up the forks. If nobody else is using them, it`s alright, if not, they are not allowed to pick up the forks so that they can avoid deadlock. There is the possibility that 4 philosophers eat in the same time and one waits. He can only start eating after one of the four finishes. They all have to wait for the waiters permission.

The logic is quite simple and it makes the game continue smoothly. Each philosopher has his left fork and waits for the right one. This entire game is an analogy for computer problems. For example the lack of forks is the same thing as  lacking of shared resources in real computer programming, also called concurrency. While locking a file or a resource a person makes sure that he is the only one that has access to it. When it`s already used by someone, the other person waits until the first one finishes. It`s a simple math problem than can be easily fixed. All the philosophers have to do is avoid deadlock and keep the game going.
If you liked this post, subscribe to our blog by filling your e-mail address below:
Delivered by FeedBurner

No comments on “Dining Philosophers Problem

Sort comments by:
Leave a comment
  • Wordpress Themes said on 06/13/2010:

    Your comment is awaiting moderation

    Nice fill someone in on and this post helped me alot in my college assignement. Thank you as your information.

Want to add something? Post your comments

  1. « previous post