Skip to content

ghostyghast/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Philosophers 👴

A dining philosophers problem simulation

42 School C

📖 About

Philosophers is a 42 project about threading and concurency. The objective is to simulate the dining philosophers problem in a program which lets you define how many philosophers are at the table as well as how long they sleep, eat and have to eat before dying.

✨ Features

  • Multi-hreaded simulation - In the philo binary, each philosopher is a thread
  • Multi-process simulation - In the philo_bonus binary, each philosopher is a process

🚀 Getting Started

Download from latest

or

Compile from source

Prerequisites

  • GCC compiler
  • Make
  1. Clone the repository
git clone https://github.com/ghostyghast/philosophers
cd philosophers/
  1. Compile the project
make -C ./philo
make -C ./philo_bonus

🔮 Usage

You must define :

  • how many philosophers are dining
  • how long they can live before having a meal in ms
  • how long they take to eat in ms
  • how long they take to sleep in ms.
  • (optionally) how many meals they have to eat before leaving the table
philo <number of philos> <life duration> <eat duration> <sleep duration> [meals to eat]

For a clearer understanding of a timeline of events, you can paste your output into this visualiser

📄 License

This project is part of the 42 School curriculum and follows the school's academic guidelines.

About

A program that similuates the dining philosophers problem

Topics

Resources

Stars

Watchers

Forks

Contributors