The Dining Philosophers Benchmark
Understand the dining philosophers' problem and asynchronous solutions in Python.
Dining philosophers problem and solution
The faculty of the College of Philosophy in an old seaside resort city (on the Atlantic coast of the US) has a long-standing tradition of dining together every Sunday night. The food is catered from Mo’s Deli, but is always—always—a heaping bowl of spaghetti. No one can remember why, but Mo’s a great chef, and each week’s spaghetti is a unique experience.
Scenario
The philosophy department is small, having five tenured faculty members. They’re also impoverished and can only afford five forks. Because the dining philosophers each require two forks to enjoy their pasta, they sit around a circular table, so each philosopher has access to two nearby forks.
This requirement for two forks to eat leads to an interesting resource contention problem, shown in the following diagram:
Get hands-on with 1400+ tech skills courses.