Skip to content

inno-aca/Philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Philosophers

The Philosophers project is part of the 42 school curriculum, challenging students to implement the dining philosophers problem using both mutexes and semaphores. This project aims to enhance understanding of parallel programming, synchronization, and resource sharing in a multi-threaded environment.

Overview

The project is divided into two parts:

Philo

The philo directory implements the dining philosophers problem using mutexes for locking. Key features include:

  • Philosopher simulation: Simulates the dining philosophers scenario with a specified number of philosophers, forks, and time constraints.
  • Mutex locking: Ensures thread-safe access to shared resources such as forks and the display.

Philo_bonus

The philo_bonus directory implements the same dining philosophers problem but uses semaphores for locking. Key features include:

  • Philosopher simulation: Simulates the dining philosophers scenario with a specified number of philosophers, forks, and time constraints.
  • Semaphore locking: Ensures thread-safe access to shared resources such as forks and the display.

Usage

  1. Clone the repository:
git clone https://github.com/seungwonme/Philosophers.git
  1. Navigate to the project directory:
cd philosophers
  1. Compile the philo or philo_bonus executable:
make
  1. Run the program with appropriate arguments:
./philo <number_of_philosophers> <time_to_die> <time_to_eat> <time_to_sleep> [number_of_times_each_philosopher_must_eat]

Example:

./philo 5 800 200 200
  • To clean up object files:
make clean
  • To delete all build files:
make fclean
  • To clean and rebuild the executable:
make re

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published