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