Skip to content

LudwigAndreas/philosophers42

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Philosophers

This project is a simulation of the dining philosophers problem. The program creates a certain number of philosophers and forks. Each philosopher can be in one of three states: eating, sleeping, thinking. The philosopher can only eat if he has two forks. The program uses threads and mutexes to synchronize the philosophers' actions.

Table of Contents

About

The dining philosophers problem is a classic synchronization problem. The problem consists of a table with five philosophers sitting around it. Each philosopher has a plate of spaghetti. A fork is placed between each pair of adjacent philosophers. A philosopher needs two forks to eat. The problem is how to design a discipline of behavior (a concurrent algorithm) such that each philosopher will not starve, i.e., each can eat forever often.

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

What things you need to install the software and how to install them.

gcc >= 7.5.0
make >= 4.1
sudo apt-get install make
sudo apt-get install gcc

Installing

A step by step series of examples that tell you how to get a development env running.

Clone the repository.

git clone https://github.com/LudwigAndreas/philosophers42

cd philosophers42

Build the project.

make

or build with bonus.

make bonus

Run the project.

./philo number_of_philosophers time_to_die time_to_eat time_to_sleep [number_of_times_each_philosopher_must_eat]

Running the tests

Explain how to run the automated tests for this system.

make test

Usage

After running the program, you will see how the philosophers are eating, sleeping, and thinking.

Built Using

  • C - Programming language
  • Make - Build automation tool

Authors

This project was developed by:

drawing LudwigAndreas

Acknowledgements

  • School 21 - Educational institution
  • 42 - Educational institution

License

This project is licensed under the School 21 License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published