Giter Club home page Giter Club logo

philosophers's Introduction

📖 Philosophers

Basics of process threading, and how work on the same memory space.


Philosophers is a 42-school project (https://www.42.fr/42-network/) which serves as an introduction to multithreading's basics.

Introduction

The dining philosophers problem is a classic example in computer science that illustrates the challenges of resource allocation and synchronization in a distributed system, using the metaphor of philosophers sharing chopsticks at a circular table. It was originally formulated in 1965 by Edsger Dijkstra.

More informations

Installation 🖥

make inside a philo folder

usage : ./philo nb_philos die_tm eat_tm sleep_tm (max_meals)

*_tm inputs are in ms and capped to 60,000 ms
max_meals argument is not required

example : ./philo 4 500 200 200

Warning: I had to comply to the subject's constraints so the code is not optimized.
These constraints were numerous. Here are a few:

• This project had to be coded in C, complying with the 42-school norm. • Any leak, crash, undefined behavior or norm error means 0 to the project.
• The only authorized mutex-related functions were pthread_mutex_init, pthread_mutex_destroy, pthread_mutex_lock, pthread_mutex_unlock.
• The philosophers must never be starving.
• Philosophers don’t speak with each other.
• Philosophers don’t know when another philosopher is about to die. • The simulation stops when a philosopher dies.
• The status printed should not be scrambled or intertwined with another philosopher’s status.
• You can’t have more than 10 ms between the death of a philosopher and when it will print its death.

Warning: Don't copy/paste code you don't understand: it's bad for you, and for the school.

philosophers's People

Contributors

leonardkrief 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.