Philosophers Project

Welcome to the Philosophers project! This project is part of the curriculum at 42 School (École 42) and involves solving the classic dining philosophers problem using concurrent programming techniques.

Introduction

The dining philosophers problem is a classic synchronization problem in computer science. It illustrates challenges in concurrent programming, resource allocation, and deadlock avoidance. In this scenario, a number of philosophers sit around a table, each spending their time thinking and eating. To eat, a philosopher must pick up the chopsticks on their left and right sides. However, the chopsticks must be shared among neighboring philosophers, leading to potential conflicts and challenges in ensuring that all philosophers can eat without encountering deadlock or starvation.

Objective

The objective of the Philosophers project is to implement a solution to the dining philosophers problem using threads (or processes) and synchronization mechanisms such as mutexes or semaphores. The solution should allow all philosophers to eat without encountering deadlock, starvation, or other concurrency issues.

Implementation

Your task is to implement a simulation of the dining philosophers problem in the programming language specified by the project requirements (typically C). Your implementation should adhere to the following guidelines:

  • Create a configurable number of philosophers and chopsticks.
  • Ensure that philosophers alternate between thinking and eating.
  • Implement synchronization mechanisms to prevent deadlocks and ensure fair access to chopsticks.
  • Handle edge cases such as philosophers dropping their chopsticks and picking them back up.

Getting Started

To get started with the Philosophers project, follow these steps:

  1. Clone this repository to your local machine.
  2. Navigate to the project directory.
  3. Execute the program according to the subject.

Resources

Here are some resources that may be helpful as you work on the Philosophers project: