Skip to content

A 42 school project that simulates the Dining Philosophers problem using multithreading (philo) and multiprocessing with semaphores (philo_bonus). The goal is to handle concurrency, synchronization, and avoid deadlocks and starvation.

Notifications You must be signed in to change notification settings

qwww-12/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿง  Philosophers (philo / philo_bonus)

libft

Project from 42 Cursus โ€“ Multithreading / Multiprocessing, Mutexes / Semaphores, and Deadlock Avoidance.

42 School project implementing the classic synchronization problem.


๐Ÿ“š Description

This project is a simulation of the classic Dining Philosophers Problem, a concurrency exercise to explore how threads/processes and synchronization mechanisms work in a system.

The bonus version uses processes and semaphores to manage access to shared resources like forks and logging.


๐Ÿ› ๏ธ Features

  • ๐Ÿงต philo: threads + mutexes
  • ๐Ÿ”€ philo_bonus: processes + semaphores
  • ๐Ÿ’€ Reaper thread to detect starvation
  • ๐Ÿ Philosophers eat, sleep, think in cycles
  • ๐Ÿ’ฅ Deadlock avoidance
  • โœ… Optional meal count support

๐Ÿงช Arguments of this project

๐Ÿง  Arguments

๐Ÿงพ Argument ๐Ÿ“– Description
number_of_philosophers ๐Ÿ‘ค Total number of philosophers (and forks)
time_to_die (in ms) ๐Ÿ’€ Time a philosopher can stay alive without eating
time_to_eat (in ms) ๐Ÿ Duration of eating
time_to_sleep (in ms) ๐Ÿ’ค Duration of sleeping
number_of_times_each_philosopher_must_eat (optional) โœ… Stop simulation when all philosophers have eaten this many times

โ–ถ๏ธ How to Use

Once compiled, run the program using the following syntax:

./philo number_of_philosophers time_to_die time_to_eat time_to_sleep [number_of_times_each_philosopher_must_eat]

About

A 42 school project that simulates the Dining Philosophers problem using multithreading (philo) and multiprocessing with semaphores (philo_bonus). The goal is to handle concurrency, synchronization, and avoid deadlocks and starvation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published