Giter Club home page Giter Club logo

philosophers's Introduction

Philosophers

πŸ—ΊοΈ Project Description

The Philosophers project involves solving the dining philosophers problem using threads and synchronization mechanisms. The aim is to find a solution where the philosophers alternate between eating, thinking, and sleeping while adhering to certain constraints to avoid resource conflicts and ensure fairness in their actions.

🍝 Key Features

Philosophers Simulation: Simulates a specific number of philosophers sitting around a table, each with their own fork and plate of spaghetti.

Concurrency & Threads: Uses threads to represent each philosopher and simulate their actions concurrently.

Eating, Thinking, Sleeping: Philosophers alternate between three states: eating, thinking, and sleeping based on specific rules to avoid conflicts.

Synchronization: Implements synchronization mechanisms (mutex, semaphore, etc.) to control access to shared resources (forks, plates, etc.) and prevent race conditions.

Avoiding Deadlock: Ensures that no deadlock occurs among the philosophers, meaning that they can continue to perform their actions without getting stuck in a state where none can proceed. So we can use mutexes to lock memory resources.

πŸš€ How to Run

To compile and execute the Philosophers program, follow these steps:

Compilation:

make

Execution:

./philo number_of_philosophers time_to_die time_to_eat time_to_sleep [optional: number_of_times_each_philosopher_must_eat]

Replace number_of_philosophers, time_to_die, time_to_eat, and time_to_sleep with appropriate numerical values for the simulation parameters. The last parameter is optional and represents the number of times each philosopher must eat before the program stops.

philosophers's People

Contributors

romann-broque 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.