Concurrency Lab: Dining Philosophers: Spring 2024
Learning Objective(s)
- Learn about the Dining Philosopher problem
- Learn to program with threads
- Experience and learn to deal with deadlocks
- Work with interfaces
Overview of the Program
Implement a number of different solutions to the Dining Philosophers problem
Specifics
- What is totally unacceptable in any form: Looking at code solutions (in any language) for the Dining Philosophers problem. It is MUCH better to implement a solution without concurrency than to even look at an existing coded solution. Get help from the professor and lab assistant!
- You may look at English discussions of the problem and concurrent code (as long as the code is not for this problem or a variation of it).
- Implement at least two solutions:
- The philosophers pick up one fork and hold it until the second become available.
- The philosophers pick up one fork. If the second fork is not available, she/he puts down the one taken, waits a small random amount of time, and tries again
- You need to use an Interface to define the requirements of a Philosopher
- The main method should be found in a program called DiningPhilosophers a This code should include a method that runs one instance of the problem. The instantiation of the philosophers is the only code that should indicate what type of philosopher is being used. a You should have two different implementations of the philosophers.
Phase 1
- Design the solution. Be sure to use examples in class to aid in this. The UML diagram might not be perfect but it should do a reasonable attempt at using concurrency
- Testing concurrency is a major challenge. This testing plan might be to keep running a problem until a number of situations occurred. You need to describe the situations that need to occur to test the program accurately. You might not be able to specifically generate them.
- Submit a Software Design Report as a single pdf
Phase 2
Using your graded software design report
- Implement at least two solutions for the philosophers. Include output to tell when the philosophers pick up and put down forks and when they eat.
- Each solution must use a form of concurrency correctly
- Run the could at least 50 times or tell a deadlock occurs, whichever comes first
- create a Software Development Report incorporating any necessary changes from the software design report. Be sure to include detailed instructions on how to run your program, including any instructions for extra credit.
- In Lessons Learned, include sections that talks about:
- the differences of the different implementations. Include the types of concurrency
- In testing report, describe how the deadlock occurred (if it did) or what would be needed to have it happen.
- create a zip folder containing only the following (and submit it)
- A completed software development report
- all the .java files needed to run
- any input files you might want to have the grader use when running the program
Submission
Optional improvements
Optional improvements should ONLY be worked on once the program is completing working. In addition, the work is to be done on your own with little if any help for lab assistants or the instructor.
- Add code to prevent a deadlock. Discuss your solution
- Solve the problem using semaphores. Once again, do not look at code (or pseudo code) that solves it. You may look at things that explain semaphores and how they are used in other situations.