Implement the classical Dining Philosophers Problem, where philosophers alternately think, eat, and sleep around a table with shared forks. This simulates synchronization, resource contention, and deadlock prevention.
A plate of spaghetti A fork to their left and fork to their right. They must:
- Think for a while
- Pick up two forks (left and right) to eat
- Eat for a while
- Sleep for a while
- Repeat...
- Practice multithreading (or multiprocessing in bonus stages).
- Ensure correct synchronization using mutexes, semaphores, or shared memory.
- Prevent deadlocks, resource starvation, and race conditions.