Skip to content

ynslee/Philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 

Repository files navigation

Project logo

Philosophers

Status GitHub Issues License


Solving threads' concurrent and deadlock problem using mutexes

📝 Table of Contents

🧐 About

The philosopher simulation is about “dining philosopher problem,” a famous problem in operating systems. The eating philosopher problem is a representative “simultaneity control” problem, in which two people must prevent two people from holding the same chopsticks (or fork) at the same time (mutual exclusion), while avoiding deadlocks where each person holds one chopstick and asks for the other person’s chopsticks.

🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Git clone the repository 

Installing

$make
$./philo [number_of_philosophers] [time_to_die] [time_to_eat] [time_to_sleep] [number_of_times_each_philosopher_must_eat]
1. number_of_philosophers : N numbers of philosophers(n amount of forks)
2. time_to_die : Philosopher will die under this circumstance(ms)
  • After the simulation started, if the philosopher doesnt eat wihtin time_to_diems after the last meal
3. time_to_eat : The amount of time(ms) it takes for the philosopher to eat
  • while eating, one philosopher needs two forks(its left side and right side)
4. time_to_sleep : The amount of time(ms) it takes for the philosopher to sleep
5. number_of_times_each_philosopher_must_eat (optionable choice)
  • Simulation stops when all the philosophers eat Nth amount of time
  • If this is not given, simulation should only stop when one of the philosopher dies

🔧 Running the tests

0 < number_of_philosophers < 200 || time_to_die > 60 || time_to_eat > 60 || time_to_sleep > 60

In case if you don't want any philosophers to die

  • If the number of philsopher is odd, it should be more than 1 philosopher, time to die should be triple the amount of time to eat, time to sleep.
$./philo 3 510 200 200
  • If the number of philsopher is even, it should be more than 1 philosopher, time to die should be triple the amount of time to eat, time to sleep.
$./philo 4 410 200 200

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published