Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSC 3 4 1 Operating Systems mmccullough 2 0 2 3 Fall Programming Assignment Five Dinning Philosophers Purpose: The purpose of this assignment is to

CSC 341 Operating Systems
mmccullough 2023 Fall
Programming Assignment Five
Dinning Philosophers
Purpose: The purpose of this assignment is to give you experience with DEADLOCK and the Dinning
Philosophers Problem.
Problem: Fix the program supplied by the instructor.
Begin with a copy of the following starter program
This assignment may not be that easy. You must read my code and understand it. Do not waste time or wait
until the last minute. Think about the problem and how so solve it before you start coding.
Solution:
Organize the waits on the semaphores so that deadlock no longer exists. Use an asymmetric solution, so one
philosopher picks up chopstick in reverse order. e.g. One philosopher picks left chopstick first (then trys for
right) or Odd-numbered philosopher picks up first the left chopstick and then the right chopstick. Evennumbered philosopher picks up first the right chopstick and then the left chopstick
So do this using one of the two following methods.
1. Break the circular wait by writing some special code for one of the philosopher (e.g. number 0)
so that he grabs right chopstick before his left chopstick.
2. Break the circular wait by writing some special code so all the even philosopher (numbers 0,2)
grabs their right chopsticks before their left chopsticks.
You will need to submit the source code for both your two solutions as a single java file for each.
Name the first solution: DiningPhilosopherZero.java
Name the second solution: DiningPhilosopherEven.java
For the source code that you will turn in, make sure you have a comment header, at the top of all the files, that
containing the following information. Your Name, The Assignment Number, Your Username
(account/logon/first part of email), etc. Do not break up into multiple files. Make sure any code you add is well
formatted with a good programming style and has generous comments, Note: you are required to VERY
clearly comment ANYTHING you change or ADD). You will be grade on your coding style as well as
functionality. You are not to change any of the code but what is necessary to break the deadlock. E.g. do not
rewrite the project. You are to only change the very minimum amount of code to fix the deadlock (two ways).
Note, you may be asked questions about your programs (how or why they work) on the exam.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

9. Explain the relationship between identity and communication.

Answered: 1 week ago

Question

a. How do you think these stereotypes developed?

Answered: 1 week ago

Question

a. How many different groups were represented?

Answered: 1 week ago