Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 1.98 KB

README.md

File metadata and controls

47 lines (34 loc) · 1.98 KB

Philosophers

🇧🇷 Para acessar a versão em português deste README clique aqui.

mandatory

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.

Code style

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.

Table of Contents

1. Description

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.

2. Usage

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]

3. Installation

Make sure you have gcc and make installed. If not, install them using your package manager.

4. Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.