Skip to content

The Philosophers project, part of the 42 curriculum, simulates the classic Dining Philosophers problem to teach concurrent programming and synchronization. It involves managing resource sharing among philosophers using threads, mutexes, and semaphores to prevent deadlock and ensure efficient operation.

Notifications You must be signed in to change notification settings

akeryan/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Philosophers project

Overview

The Philosophers project, part of the 42 curriculum, is a classic synchronization problem designed to teach the fundamentals of concurrent programming and resource sharing. The project simulates a scenario where philosophers sit around a table, each alternating between thinking and eating. The challenge lies in managing the limited resources (forks) and preventing deadlock and starvation.

Features

  • Concurrency Handling: Implements multiple threads to simulate philosophers' activities.
  • Synchronization: Utilizes mutexes and/or semaphores to manage access to shared resources.
  • Deadlock Prevention: Incorporates strategies to prevent deadlock and ensure that each philosopher gets a chance to eat.
  • Thread Safety: Ensures safe and efficient handling of concurrent operations.

Technical Details

  • Threads: Each philosopher is represented by a separate thread, running independently.

  • Mutexes: Used to control access to forks and ensure that no two philosophers can hold the same fork simultaneously.

  • State Management: Philosophers' states (thinking, hungry, eating) are carefully managed to avoid race conditions.

    Installation

    To build and run the Philosophers project, follow these steps:

    1. Clone the repository:
    2. Compile the project:
      • make
    3. Run the simulation:
      • ./philo

Usage

Upon running the simulation, you will see the philosophers alternating between thinking and eating, with proper synchronization ensuring that no two philosophers use the same fork simultaneously.

About

The Philosophers project, part of the 42 curriculum, simulates the classic Dining Philosophers problem to teach concurrent programming and synchronization. It involves managing resource sharing among philosophers using threads, mutexes, and semaphores to prevent deadlock and ensure efficient operation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published