Issue 2: 1.8 Exercise 1
Project Member Reported by sergeypr...@gmail.com, Aug 21, 2014
Exercise 1. The dining philosophers problem was invented by E. W. Dijkstra, a
concurrency pioneer, to clarify the notions of deadlock and starvation freedom.
Imagine five philosophers who spend their lives just thinking and feasting. They
sit around a circular table with five chairs. The table has a big plate of rice. However,
there are only five chopsticks (in the original formulation forks) available,
as shown in Fig. 1.5. Each philosopher thinks.When he gets hungry, he sits down
and picks up the two chopsticks that are closest to him. If a philosopher can pick
up both chopsticks, he can eat for a while. After a philosopher finishes eating, he
puts down the chopsticks and again starts to think.
1. Write a program to simulate the behavior of the philosophers, where each
philosopher is a thread and the chopsticks are shared objects. Notice that you
must prevent a situation where two philosophers hold the same chopstick at
the same time.
2. Amend your program so that it never reaches a state where philosophers are
deadlocked, that is, it is never the case that each philosopher holds one chopstick
and is stuck waiting for another to get the second chopstick.
3. Amend your program so that no philosopher ever starves.
4. Write a program
Aug 21, 2014
Project Member #1 sergeypr...@gmail.com
Design of solution here https://projects-education.googlecode.com/svn/trunk/doc/Chapter_1/1.1.vsd (only for 1.1 task)
Sep 4, 2014
Project Member #2 sh.ba...@gmail.com
The diagram completely is OK. Good job!
I'm waiting with interest the results for points 2-3 :)
Oct 16, 2014
Project Member #4 sh.ba...@gmail.com
It is good. But it would be better write code, after diagramming.