GithubHelp home page GithubHelp logo

juricakenda / dining-philosophers Goto Github PK

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

A classic example problem often used in concurrent algorithm design.

Java 100.00%
concurrent-programming dining-philosophers-problem dining-philosophers algorithm-challenges

dining-philosophers's Introduction

Dining Philosophers (Out of this world)

This program represents the classic dining philosophers problem with an extra twist. The dining philosophers problem is an example problem often used in concurrent algorithm design to illustrate synchronization issues and techniques for resolving them. The philosophers are sitting at a table and all they can ever do is thing or eat. There is a limited amount of chopsticks (which they need to eat) on the table, and each philosopher has a different number of hands (there is the extra twist). Problem is solved using the monitor functions and mutex locks.

Getting Started

To get started with looking into the code and testing this program simply download the "DiningPhilosophers" file in this repository. Along with that you will also need to download (and perhaps reconfigure) the "testFile.txt" file. See more detailed explanations below.

Prerequisites

None.

Standard Java libraries.

Installing

This program is intented to be run and tested in IDE or Command Prompt, and not as an application.

Step one:

Download the files (DiningPhilosophers.java and testFile.txt)

Step two:

Open the DiningPhilosophers.java file and reconfigure the Path to testFile.txt the way it is located in your computer. You will find the Path String in the very constructor of the class.

Step three:

Open the testFile.txt and reconfigure the numbers.
Text file should be formatted in this manner : 
FIRST_LINE -> numberOfPhilosophers " " number of chopsticks
SECOND_LINE -> numberOfHands1 " " numberOfHands2 " " ... for each philosopher

where " " represents an empty space between the data. 

Final step:

Run the main class within the DiningPhilosophers file and observe the result. 

Running the tests

There are no specific tests to run for this program other than observing the results and making sure they obey the rules. In the display you will se which philosophers are eating at the same time. At the very top of the display is a guide which reminds you how many hands does each philosopher have. If the number of hands currently eating is greater than the number of chopsticks on the table, something is obviously wrong.

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

dining-philosophers's People

Contributors

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