Skip to content

This project implements the classic Dining Philosophers Problem using Pthreads and semaphores in C++.

License

Notifications You must be signed in to change notification settings

atellaluca/dining-philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🍽️ Dining Philosophers Problem with Pthreads

Dining Philosophers Problem

GitHub issues GitHub stars GitHub forks GitHub license

📖 Overview

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 🏛️

✨ Features

  • 🧩 Implements the dining philosophers problem
  • 🧵 Thread management with Pthreads
  • 🛡️ Synchronization using semaphores
  • 📊 Displays philosopher status (thinking, eating, waiting)

🏗️ Project Structure

  • dining-philosophers.cpp: Main source code for the project.

🚀 How to Run

  1. Clone this repository:
    git clone https://github.com/atellaluca/dining-philosophers.git
  2. Compile the program:
    g++ -o philosophers dining-philosophers.cpp -lpthread
  3. Run the executable:
    ./philosophers
    

Dining Philosophers run

🏷️ Topics

  • 🧠 dining-philosophers
  • 🧵 pthreads
  • 🔐 semaphores
  • 🔄 synchronization
  • ⚙️ multithreading
  • 💻 cpp
  • 🛠️ operating-systems
  • 🧮 resource-management

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

Releases

No releases published

Packages

No packages published

Languages