Skip to content

0verLighT/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project has been created as part of the 42 curriculum by amartel

Philosophers

thread ist tot

Special thank to amblanch, my goat 🐐🐐 for help me with helgrind and some data race.

Description

This project is a simulation of the dining philosophers problem, it using the pthread library to create threads and mutexes to synchronize them. the program takes 4 arguments:

  • number_of_philosophers: the number of philosophers
  • time_to_die: if a philosopher doesn't start eating time_to_die milliseconds after starting their last meal or the beginning of the simulation, they die.
  • time_to_eat: the time it takes for a philosopher to eat. During that time, they will need to hold the two forks on their left and right.
  • time_to_sleep: the time a philosopher will spend sleeping.
  • eat_before_end (optional argument): if all philosophers eat at least eat_before_end times, the simulation stops. If not specified, the simulation stops when a philosopher dies.

Instructions

You can use flake.nix with nix develop (or direnv), it's require Nix flakes

Makefile

cd philo
make -j8
./philo 5 500 200 100

meson.build

cd philo
meson setup build --prefix=$PWD --bindir=.
meson install -C build
./philo 5 500 200 100

Resources

  • Developpez pthread (FRENCH)
  • 42 student : some advises (how to create dead logic, parser with ft_atoi)
  • IA was used to correct the typo in the README.md, and to understand the routine in library pthread.
  • amblanch : My goat 🐐🐐

About

thread ist tot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors