Task 1 Submitted Lab Solution Dinning Philosopher Problem Given Although Solution Guarant Q43804646
Task 1 (to be submitted in the lab) Solution to dinning-philosopher problem is given below. Although this solution guarantees that no two neighbours are eating simultaneously, it nevertheless must be rejected because it could create deadlock. Suppose that all five philosophers become hungry at the same time and each grabs her right chopstick. All the elements of chopstick will now be equal to 0. When each philosopher tries to grab her left chopstick, she will be delayed forever. Several possible remedies to the deadlock problem are replaced by: 1. Allow at most four philosophers to be sitting simultaneously at the table. 2. Allow a philosopher to pick up her chopsticks only if both chopsticks are available (to do this, she must pick them up in a critical section). 3. Use an asymmetric solution-that is, an odd-numbered philosopher picks up first her left chopstick and then her right chopstick, whereas an even numbered philosopher picks up her right chopstick and then her left chopstick. Dinning-philosopher basic solution wait (chopstick[i]); wait (chopstick[ (i+1) % 5]); /* eat for a while */ signal (chopstick[i]); signal (chopstick[(i+1) % 5]); /* think for a while */ Problem: Incorporate all of the three solutions one by one to the basic solution for deadlock free execution of the code. You are required to submit each solution in a separate file. Show transcribed image text Task 1 (to be submitted in the lab) Solution to dinning-philosopher problem is given below. Although this solution guarantees that no two neighbours are eating simultaneously, it nevertheless must be rejected because it could create deadlock. Suppose that all five philosophers become hungry at the same time and each grabs her right chopstick. All the elements of chopstick will now be equal to 0. When each philosopher tries to grab her left chopstick, she will be delayed forever. Several possible remedies to the deadlock problem are replaced by: 1. Allow at most four philosophers to be sitting simultaneously at the table. 2. Allow a philosopher to pick up her chopsticks only if both chopsticks are available (to do this, she must pick them up in a critical section). 3. Use an asymmetric solution-that is, an odd-numbered philosopher picks up first her left chopstick and then her right chopstick, whereas an even numbered philosopher picks up her right chopstick and then her left chopstick. Dinning-philosopher basic solution wait (chopstick[i]); wait (chopstick[ (i+1) % 5]); /* eat for a while */ signal (chopstick[i]); signal (chopstick[(i+1) % 5]); /* think for a while */ Problem: Incorporate all of the three solutions one by one to the basic solution for deadlock free execution of the code. You are required to submit each solution in a separate file.
Expert Answer
Answer to Task 1 (to be submitted in the lab) Solution to dinning-philosopher problem is given below. Although this solution guara…
OR