Git Product home page Git Product logo

philosophers's Introduction

codam logo

❔ Basic Overview

Philosophers is a part of Codam (42 network) curriculum for 2020 cohort. The aim of this project is to learn the basics of threading a process, making threads, using mutex.

The assignment is based on the Dining Philosophers Problem originally formulated in 1965.

Philosophers dine together at the same table. Each philosopher has their own plate at the table. There is a fork between each plate. The dish served is a kind of spaghetti which has to be eaten with two forks. Each philosopher can only alternately think and eat. Moreover, a philosopher can only eat their spaghetti when they have both a left and right fork. Thus two forks will only be available when their two nearest neighbors are thinking, not eating. After an individual philosopher finishes eating, they will put down both forks.

πŸ₯„ πŸ‘΄ πŸ₯„
πŸ‘΄ 🍝 πŸ‘΄
πŸ₯„ πŸ‘΄ πŸ₯„

βš™οΈ Options

Name Description
number_of_philosophers the number of philosophers and also the number of forks
time_to_die if a philosopher doesn’t start eating ’time_to_die’ milliseconds after starting his last meal or the beginning of the simulation, it dies
time_to_eat the time it takes for a philosopher to eat. During that time he will need to keep the two forks
time_to_sleep the time the philosopher will spend sleeping
number_of_times_each_philosopher_must_eat 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.

πŸ–₯️ Output

β—¦ timestamp_in_ms X has taken a fork
β—¦ timestamp_in_ms X is eating
β—¦ timestamp_in_ms X is sleeping
β—¦ timestamp_in_ms X is thinking
β—¦ timestamp_in_ms X died

philosophers's People

Contributors

kmoroz avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.