Question: (a) Given the following solution for the critical section problem for two processes (the code shown is for processes Pi), show why it does not

(a) Given the following solution for the critical section problem for two processes (the code shown is for processes Pi), show why it does not satisfy the mutual exclusion requirement. Here, turn, flag[i[], and flag[j] are is shared variables; flag[i] and flag[j] are initialized to FALSE and turn initialized to i. (Indicate one scenario where the mutual exclusion requirement is violated.) do {flag[i] = true; turn = i; while (flag[j] && turn == j); Critical section flag[i] = FALSE; Remainder section} (b) What happens if flag[i] and flag[j] are set to TRUE in the above code? Three processes P1, P2, and P3 are sharing a resource R1 in a mutually exclusive manner. Using test_and_set instruction, show code for PI, P2, and P3 that shows the entry section and exit section (similar to the code shown in Question 1). Using this code, show a scenario if all three processes want to enter their critical sections
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
