Back
To Chapter 2
Classical Problems in Process Synchronization
-
Bounded Buffers
-
Readers/Writers
-
Dinning Philosophers
Dinning Philosophers:
-
There are 5 philosophers seated around a circular table.
-
Each philosopher has a plate of spaghetti.
-
A philosopher needs two forks to eat spaghetti.
-
Between each pair of plates is one fork.
-
Principle: if you do not have both forks at same time, then release your
fork from your hand.
Deadlock - circular wait list. If every philosopher picks
up right fork, no one can eat it.
Starvation - infinitely blocked. If wait for others finishing,
it may never have chances to eat.
The Dinning Philosophers problem may apply to the situation you must
have disk drive and printer to do your jobs (That is, you need two resources).
Deadlock free:
If no one beside you is eating and you are hungry, then
eat it.
Starvation free
Set up priority:
-
I am hungry before you.
-
I am more hungry than you.