Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 1.2 KB

README.md

File metadata and controls

29 lines (24 loc) · 1.2 KB

Philosophers

I’ve never thought philosophy would be so deadly.
In this project, I learned the basics of threading a process and mutexes.

Here you can read more about the problem https://en.wikipedia.org/wiki/Dining_philosophers_problem

Screenshot 2022-03-27 at 20 34 58

Introduction

- philo number: how many philosophers are sitting at the table
- time to die: time in milliseconds until a philo dies after his last meal
- time to eat: time in milliseconds it takes a philo to eat
- time to die: time in milliseconds it takes a philo to sleep
- number must eat: how many times a philo must at least have eaten to end the simulation

A philosopher has to announce its current status in the STDOUT, which can be:

  • philo n has taken a fork
  • philo n is eating
  • philo n is sleeping
  • philo n is thinking
  • philo n died

Usage

make to compile all source files
./philo <philo number> <time to die> <time to eat> <time to sleep> <number must eat> to start the simulation