Question: 10. The classic solution to the Dining Philosophers problem may deadlock. The modified version illustrated in Figure 2 tries to solve the deadlock problem. The

10. The "classic" solution to the Dining Philosophers problem may deadlock. The modified version illustrated in Figure 2 tries to solve the deadlock problem. The modification is the following: when the philosophers are obtaining the left chopstick, they specify that they will only wait 1 second. If 1 second passes without obtaining the chopstick, false is returned and the philosopher returns the right chopstick and starts again. With this in mind answer the following questions: (6 points) a. Is the deadlock problem solved (justify your answer)? [3 points) b. If the variable, controller.sleep Time() is set to 0 (used in line 4), will this influence the behavior of the application in an undesirable way (justify your answer by showing traces of the program which are desirable/undesirable)? 3 points) 1) while (true) { 2) // Thinking 3) view.setPhil(identity, view. THINKING); 4) sleep(controller.sleepTime()); // Hungry view.setPhil(identity,view.HUNGRY); 5) 6) 7) 8) 9) 10) 11) 12) 13) 14) 15) 16) 17) 18) 19) 20) 21) right.get(); // Wait forever until I can get // the right chopstick // Got right chopstick view.setPhil(identity, view. GOTRIGHT); sleep(500); if (left.get(1000)) { // Try to get left // chopstick for 1 second // Eating view.setPhil(identity,view.EATING); sleep(controller.eatTime(); // Done eating return both chopsticks right.put(); left.put(); } else { right.put(); // Since left chopstick was not // obtained, return the right chopstick 22) 23) 24) 25) } 26) }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
