Mutual Exclusion Consider the following program that aims to solve the critical section problem for 2 processes P0 and P1
1: var blocked: array [0..1] of boolean; 2: turn: 0..1; 3: procedure P (id: integer); 4: begin 5: repeat 6: blocked[id] := true; 7: while turn != id do 8: begin 9: while blocked[1-id] do no-op; 10: turn := id; 11: end; 12: < critical section > 13: blocked[id] := false; 14: < remainder > 15: until false 16: end 18: begin 19: blocked[0] := false; blocked[1] := false; 20: turn := 0; 21: parbegin 22: P(0); P(1) 23: parend 24: end This is a proposed software solution to the mutual exclusion problem. Explain what mutual exclusion is. Does this solution solve the mutual exclusion problem? Explain why or why not
Join our real-time social learning platform and learn together with your friends!