This project has been created as part of the 42 curriculum by amartel
thread ist tot
Special thank to amblanch, my goat 🐐🐐 for help me with helgrind and some data race.
This project is a simulation of the dining philosophers problem, it using the pthread library to create threads and mutexes to synchronize them.
the program takes 4 arguments:
number_of_philosophers: the number of philosopherstime_to_die: if a philosopher doesn't start eatingtime_to_diemilliseconds after starting their last meal or the beginning of the simulation, they die.time_to_eat: the time it takes for a philosopher to eat. During that time, they will need to hold the two forks on their left and right.time_to_sleep: the time a philosopher will spend sleeping.eat_before_end(optional argument): if all philosophers eat at leasteat_before_endtimes, the simulation stops. If not specified, the simulation stops when a philosopher dies.
You can use flake.nix with nix develop (or direnv), it's require Nix flakes
Makefile
cd philo
make -j8
./philo 5 500 200 100meson.build
cd philo
meson setup build --prefix=$PWD --bindir=.
meson install -C build
./philo 5 500 200 100- Developpez pthread (FRENCH)
- 42 student : some advises (how to create dead logic, parser with ft_atoi)
- IA was used to correct the typo in the README.md, and to understand the routine in library pthread.
- amblanch : My goat 🐐🐐