Philosophers

C · pthreads

The dining-philosophers concurrency problem, using threads, per-fork mutexes, and a monitor thread.

View on GitHub
The dining-philosophers simulation running in the terminal

A solution to the classic dining-philosophers problem, written in C with POSIX threads. Philosophers sit around a table alternating between eating, sleeping, and thinking. Each needs the two forks next to it to eat, and the simulation has to run without deadlocks and without any philosopher starving.

How it works

← All projects