Skip to content

Tarchimb/philosophers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

Philosophers

This project represent the dining philosopher problem, using threads and mutex.

Table of contents

General information

This is the subject from 42 school, philosopher's. We've got n philosopher sitting around a table, with a bowl of spaghetti in the center of the table. Each philosopher, represented by a thread, has 1 fork at his left, and need 2 fork to eat. Each fork is represented by a mutex. The philosopher's eat, sleep or think. They have to start eating before time_to_die is superior to they're last meal, or the start of the simulation, or they will die. If a philosopher die, the simulation should stop.

One of the problem was to avoid a deadlock situation : all the philosophers took a fork, and nobody can eat, because they need two fork to eat.

The simulation will stop if a philosopher die, or if each philosopher eats number_of_eats_needed.

Usage

git clone the project, then make it

to launch it :

./philo [number_of_philo][time_to_die_in_ms][time_to_eat_in_ms][time_to_sleep_in_ms][number_of_eats_needed(optionnal)]

Screenshots

## Project status The project is actually finished. ## Room for improvement

Instead of using one thread per philosopher's you can use one process, and start the simulation with all the fork in the middle of the table.

Contact

Created by tarchimb(tharchimb@gmail.com), feel free to contact me!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published