This is a simulation of the dining philosophers problem
Philosopher | Thinking | Hungry | Eating |
---|---|---|---|
1 | Yes | - | - |
2 | Yes | - | - |
3 | Yes | - | - |
4 | Yes | - | - |
5 | Yes | - | - |
Philosopher 1
Philosopher 5
Philosopher 2
Philosopher 4
Philosopher 3
The dining philosopher's problem is the classical problem of synchronization which says that Five philosophers are sitting around a circular table and their job is to think and eat alternatively. A bowl of noodles is placed at the center of the table along with five chopsticks for each of the philosophers. To eat a philosopher needs both their right and a left chopstick. A philosopher can only eat if both immediate left and right chopsticks of the philosopher is available. In case if both immediate left and right chopsticks of the philosopher are not available then the philosopher puts down their (either left or right) chopstick and starts thinking again.
The dining philosopher demonstrates a large class of concurrency control problems hence it's a classic synchronization problem.