Question: 2. Write a program to solve the dining philosophers problem. Dining philosophers is a classic synchronization problem. Five silent philosophers sit around a table with

2. Write a program to solve the dining philosophers problem. Dining philosophers is a classic synchronization problem. Five silent philosophers sit around a table with a bowl of rice. A chopstick is placed between each pair of adjacent philosophers. Each philosopher must alternately think and eat. Eating is not limited by the amount of rice left: assume an infinite supply. However, a philosopher can only eat while holding both the chopstick to the left and the chopstick to the right. Each philosopher can pick up an adjacent chopstick, when available, and put it down when holding it. These are separate actions: chopsticks must be picked up and put down one by one. The problem is how to design a discipline of behavior such that each philosopher won't starve, i.e. can forever continue to alternate between eating and thinking.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!