Eat, Sleep, Spaghetti, repeat. This project is about learning how threads work by precisely timing a group of philosophers on when to pick up forks and eat spaghetti without dying from hunger.
At 42 School, almost every project must be written in accordance to the Norm, the school's coding standard. As a result, the implementation of certain parts may appear strange and for sure had room for improvement.
To use this project, compile the project and run the program with the following arguments :
number_of_philosophers time_to_die time_to_eat time_to_sleep [number_of_times_each_philosopher_must_eat]
-
number_of_philosophers: The number of philosophers and also the number of forks.
-
time_to_die (in milliseconds): If a philosopher didn’t start eating time_to_die milliseconds since the beginning of their last meal or the beginning of the simulation, they die.
-
time_to_eat (in milliseconds): The time it takes for a philosopher to eat. During that time, they will need to hold two forks.
-
time_to_sleep (in milliseconds): The time a philosopher will spend sleeping.
-
number_of_times_each_philosopher_must_eat (optional argument): If all philosophers have eaten at least number_of_times_each_philosopher_must_eat times, the simulation stops. If not specified, the simulation stops when a philosopher dies.
Example :
$ ./philo 4 410 200 200
To install the project, clone this repository :
$ [email protected]:julienhouyet/42-philosophers.git
To compile the project, run :
$ make
To re-compile the project :
$ make re
To wipes all object files :
$ make clean
To delete the project and all object files
$ make fclean