Project from 42 Cursus โ Multithreading / Multiprocessing, Mutexes / Semaphores, and Deadlock Avoidance.
42 School project implementing the classic synchronization problem.
This project is a simulation of the classic Dining Philosophers Problem, a concurrency exercise to explore how threads/processes and synchronization mechanisms work in a system.
The bonus version uses processes and semaphores to manage access to shared resources like forks and logging.
- ๐งต
philo
: threads + mutexes - ๐
philo_bonus
: processes + semaphores - ๐ Reaper thread to detect starvation
- ๐ Philosophers eat, sleep, think in cycles
- ๐ฅ Deadlock avoidance
- โ Optional meal count support
๐งพ Argument | ๐ Description |
---|---|
number_of_philosophers |
๐ค Total number of philosophers (and forks) |
time_to_die (in ms) |
๐ Time a philosopher can stay alive without eating |
time_to_eat (in ms) |
๐ Duration of eating |
time_to_sleep (in ms) |
๐ค Duration of sleeping |
number_of_times_each_philosopher_must_eat (optional) |
โ Stop simulation when all philosophers have eaten this many times |
Once compiled, run the program using the following syntax:
./philo number_of_philosophers time_to_die time_to_eat time_to_sleep [number_of_times_each_philosopher_must_eat]