Skip to content

my take on the famous dining philosopher problem

Notifications You must be signed in to change notification settings

idleira/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

philosophers - @42Wolfsburg

description

philosophers is a project centered on learning the basics of process threading and mutexes.

it is a variation on the famous dining philosophers problem.

dining cats

here are some of the sources that i used:

multithreading in c

threads, mutexes and concurrent programming in c

the dining philosophers problem

philosophers 42 guide

• a very handy philosophers visualizer by nfukada

the dining philosophers problem

history

this problem is a common challenge in computer science.

it is often used to show difficulties in designing algorithms that run at the same time and in coordinating processes.

it was first introduced in 1965 by edsger dijkstra as part of a student exam and was originally explained using computers competing for access to tape drives.

subject

here's how our subject articulates this problem:

• one or more philosophers sit at a round table;

• there is a large bowl of spaghetti in the middle of the table;

• the spaghetti can only be eaten with two forks;

• there are only as many forks as there are philosophers;

• each philosopher successively eats, sleeps and thinks;

• if a philosopher hasn't eaten in a certain timeframe, he will die of starvation;

• philosophers cannot communicate with each other.

usage

  1. clone this repository: git@github.com:idleira/philosophers.git philosophers && cd philosophers/philo;

  2. use make to compile the project;

  3. run the program with ./philo (number_of_philosophers) (time_to_die) (time_to_eat) (time_to_sleep)

    • you can add an optional [number_of_times_each_philosopher_must_eat] at the end too;

    • for example: ./philo 5 800 200 200 or ./philo 5 800 200 200 7

  4. to clean up:

    • use make clean to remove .o files;

    • use make fclean to clean up the project directory by removing all generated files.

my final grade:

philo grade

Releases

No releases published

Packages

No packages published