🇧🇷 Para acessar a versão em português deste README clique aqui.
This project simulates the classic dining philosophers problem using threads and mutexes. The goal is to avoid deadlocks while ensuring that each philosopher can eat without conflicts.
The code style used in this project is the Norminette created by the 42 school and used in all related ANSI C projects in the context of the school.
The dining philosophers problem involves a group of philosophers sitting around a circular table. Each philosopher thinks and eats. To eat, a philosopher must pick up both forks (one on their left and one on their right). However, if all philosophers try to pick up their forks simultaneously, they can deadlock.
This project provides a solution to the problem using threads and mutexes. It ensures that philosophers can eat without causing deadlocks.
Clone the repository:
git clone https://github.com/LeonardoSabar/Philosophers_42SP.git
Compile the program:
cd philosophers
make
Run the simulation:
./philo [number_of_philosophers] [time_to_die] [time_to_eat] [time_to_sleep] [number_of_times_each_philosopher_must_eat]
Make sure you have gcc and make installed. If not, install them using your package manager.
Contributions are welcome! Feel free to open issues or submit pull requests.