This repository contains an implementation of the classic Dining Philosophers Problem 🧠, using Pthreads and semaphores in C++. The problem showcases process synchronization, where five philosophers 🧑🎓 share limited resources (forks 🍴) to alternate between eating 🍝 and thinking 🤔. The solution ensures safe resource allocation and deadlock prevention 🔒.
This project was included until a few years ago as an example in the Operating Systems course at the University of Basilicata, led by Professor Domenico Daniele Bloisi 🏛️
- 🧩 Implements the dining philosophers problem
- 🧵 Thread management with Pthreads
- 🛡️ Synchronization using semaphores
- 📊 Displays philosopher status (thinking, eating, waiting)
dining-philosophers.cpp
: Main source code for the project.
- Clone this repository:
git clone https://github.com/atellaluca/dining-philosophers.git
- Compile the program:
g++ -o philosophers dining-philosophers.cpp -lpthread
- Run the executable:
./philosophers
- 🧠 dining-philosophers
- 🧵 pthreads
- 🔐 semaphores
- 🔄 synchronization
- ⚙️ multithreading
- 💻 cpp
- 🛠️ operating-systems
- 🧮 resource-management
This project is licensed under the MIT License - see the LICENSE file for details.