Skip to content

Réalisation du diner des philosophes avec des mutex, sémaphores et des fork.

Notifications You must be signed in to change notification settings

vvaucoul/Philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Philosophers

Realization of the problem of the philosophers' dinner with mutex, semaphores and fork.

Usage

  • Clone Repository
git clone https://github.com/vvaucoul/Philosophers && cd Philosophers
  • Compilation
cd [philo_one / philo_two / philo_three] && make
  • philo_one: Threads and mutex

  • philo_two: Threads and semaphores

  • philo_three: Forks and mutex

  • Start philosopher

./philo_[X] [number_of_philosophers] [time_to_die] [time_to_eat] [time_to_sleep] [number_of_times_each_philosopher_must_eat(optional)]
  • number_of_philosophers: The number of philosophers, but also the number of forks.
  • time_to_die: If a philosopher hasn’t started eating time_to_die milliseconds after the start of his previous meal or from the Start simulation, he dies.
  • time_to_eat: The time a philosopher takes to eat. Meanwhile, a philosopher must keep his two forks.
  • time_to_sleep: The time a philosopher spends sleeping.
  • number_of_times_each_philosopher_must_eat(optional): If all philosophers ate at least number_of_times_each_philosopher_must_eat If this argument is not specified, then the simulation ends with the death of a philosopher.

Examples

./philo_one 3 500 400 200
./philo_two 4 1200 300 100
./philo_three 2 1700 500 300 7

Animation

About

Réalisation du diner des philosophes avec des mutex, sémaphores et des fork.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published