The Philosophers project at 42 explores the concepts of threading and process synchronization within the context of the famous Dining Philosophers Problem. The challenge involves simulating a scenario where philosophers sit around a table, alternating between eating, thinking, and sleeping without running into deadlocks.
- Utilizes POSIX threads to simulate the actions of each philosopher.
- Implements mutexes for managing access to shared resources, such as forks.
- Avoids potential deadlocks and ensures no philosopher starves.
To clone the repository, use:
git clone https://github.com/moop250/philosophers.gitCompilation & cleanup:
make: Compiles the code.make clean: Would clean up object files (.o) if there were any.make fclean: Cleans up all files generated by the make command, including the executable.make re: Executes make fclean followed by make to recompile all the code.
Example usage:
./philosophers number_of_philosophers time_to_die time_to_eat time_to_sleep [number_of_times_each_philosopher_must_eat]