Skip to content

swaan-miller/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

philosophers

Codam [42 Network] project: the aim of this project is to create a multi-threaded program to solve the classic computer science "dining philosophers" problem. This is done using mutexes to protect shared resources while ensuring there are no data races or race conditions.

Details

  • the program takes 4 arguments with an optional 5th argument
  • 1st argument: # of philosophers
  • 2nd argument: time until death (if they don't start eating within this timeframe they will die)
  • 3rd argument: time spent eating
  • 4th argument: time spent sleeping
  • 5th argument (optional): # of times they must eat (ie: they each must eat 3 times and then the simulation stops)

Run

  • make to compile
  • examples to run:
    • ./philo 5 800 200 200 no one should die
    • ./philo 5 800 200 200 7 they should each eat 7 times and then the simulation stops, no one should die
    • ./philo 1 800 200 200 philo dies because there is only one fork, needs two to eat
    • ./philo 4 410 200 200 no one should die
    • ./philo 4 310 200 100 a philo should die
    • ./philo 2 60 60 60 a philo should die

Skills

  • Unix
  • Rigor
  • Imperative Programming

Objectives

  • Unix logic



About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published