Skip to content

Three solutions for the classical Dining Philosophers problem

Notifications You must be signed in to change notification settings

a-cha/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dining Philosophers

The purpose of the project is to solve the classical Dining Philosophers problem.

In the task's context philosophers considered as processes and forks as resources. The main aim of the task is to avoid the deadlock.

There are three different solutuions:

  • philo_one - philosophers as threads, forks as mutexes
  • philo_two - philosophers as threads, forks as semaphores
  • philo_three - philosophers as processes, forks as semaphores

Usage

Run make inside the philo_one/two/three directory to create a binary file.

Run the program like ./philo_one 5 600 200 100 10 with some necessary arguments.

What is arguments?
  1. Number of philosophers (5) - is the number of philosophers and also the number of forks
  2. Time to die (600) - is in milliseconds, if a philosopher doesn’t start eating ’time_to_die’ milliseconds after starting his last meal, he dies
  3. Time to eat (200) - is in milliseconds and is the time it takes for a philosopher to eat
  4. Time to sleep (100) - is in milliseconds and is the time the philosopher will spend sleeping
  5. Number of times each philosopher must eat (10) - argument is optional, if all philosophers eat at least ’number_of_times_each_philosopher_must_eat’ the simulation will stop. If not specified, the simulation will stop only at the death of a philosopher

About

Three solutions for the classical Dining Philosophers problem

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published