This is a project for the 42 cursus that focuses on the dining philosophers problem. The goal of this project is to implement a solution to the problem using multithreading and synchronization techniques while writing a C
program.
The dining philosophers problem is a classic synchronization problem in computer science. It involves a group of philosophers sitting around a table, where each philosopher alternates between thinking and eating. The problem arises when each philosopher requires two forks to eat, but there are only a limited number of forks available.
In this project, we aim to solve this problem by implementing a solution using threads and mutex locks.
Before any installation, make sure you are unsing an LTS stable Linux version that compiles C programs with cc
compiler. If not, proceed with the following command on your terminal in order to install cc
compiler:
sudo apt install cc
To install and run the philosophers project, follow these steps:
- Clone the repository:
git clone https://github.com/shexweeknd/42-cursus-Philosophers.git
- Navigate to the project directory:
cd 42-cursus-Philosophers/philo
- Compile the project with the command:
make
- Run the program:
./philo [number_of_philosophers] [time_to_die] [time_to_eat] [time_to_sleep] [number_of_times_each_philosopher_must_eat]
Once the program is running, the philosophers will start their dining process. The program will output the actions of each philosopher, such as when they start eating, finish eating, start sleeping, etc. The program will terminate when a philosopher dies or when all philosophers have eaten the required number of times.
Contributions to the philosophers project are welcome. If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
This project is from 42 School Common Core Cursurs. I do not own any of the concept mentionned above. Instead I own the provided code in the repository.
Licensed under the MIT License.
- 42 Network for providing the project.
- Axian Group