Consider Peterson's algorithm for mutual exclusion between two concurrent…
GATE · Computer Science · 2001
Consider Peterson's algorithm for mutual exclusion between two concurrent processes i and j. The program executed by process i is shown below.
repeat
flag[i] = true;
turn = j;
while (P) do no-op;
enter critical section, perform actions, and exit critical section;
flag[i] = false;
perform other non-critical-section actions;
until false;
For the program to guarantee mutual exclusion, the predicate P in the while loop should be:
- A.
flag[j] == true and turn == i
- B.
flag[j] == true and turn == j
- C.
flag[i] == true and turn == j
- D.
flag[i] == true and turn == i
Attempted by 407 students.
Sign up free to check your answer
Sign up freeLoading lesson…