GithubHelp home page GithubHelp logo

antoinecousi / philo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 913 KB

Implementation in C of the Dining Philosophers problem, tackling challenges in concurrency, thread management, and resource allocation.

Makefile 2.76% C 97.24%
c

philo's Introduction

Philosophers Project

Overview

The Philosophers project is an implementation of the classic Dining Philosophers problem in computer science. This project aims to explore and solve the challenges of concurrency, thread management, and resource allocation. It serves as a practical demonstration of avoiding common issues such as deadlock, starvation, and race conditions.

Features

  • Concurrency Handling: Utilizes multiple threads or processes to simulate the philosophers.
  • Resource Management: Efficiently manages resources (forks) among philosophers to avoid deadlock.
  • Philosopher States: Implements different states for each philosopher - thinking, eating, and sleeping.
  • Time Management: Controls the timing for eating, sleeping, and thinking to prevent starvation.
  • Deadlock Prevention: Implements algorithms to prevent deadlock and ensure fair resource allocation.

Installation

git clone [email protected]:Antoinecousi/Philo.git
cd Philo
make

Usage

Run the program with the following command:

./philo [number of philosophers] [time to die] [time to eat] [time to sleep] [number of times each philosopher must eat (optional)]

Problem Description

The Dining Philosophers problem consists of the following scenario: A certain number of philosophers are sitting around a circular table doing one of three things - eating, thinking, or sleeping. While eating, they are not thinking or sleeping; while sleeping, they are not eating or thinking; and, of course, while thinking, they are not eating or sleeping. The philosophers sit at a circular table with a large bowl of spaghetti in the center. A fork is placed between each pair of adjacent philosophers; each philosopher has one fork to their left and one to their right. As spaghetti is difficult to serve and eat with a single fork, it is assumed that a philosopher must eat with two forks, one from their left and one from their right.

philo's People

Contributors

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