Consider Peterson's algorithm for mutual exclusion between two concurrent…

GATE · 2001 · CS · Question 2 subpartsModified — slightly modified from the official paper; see the solution

Consider Peterson's algorithm for mutual exclusion between two concurrent processes i and j. The program executed by process i is shown below.

Here i identifies the process whose program is shown, and j denotes the other process.

Repeat

flag[i] = true;

turn = j;

while(P) do no-op;

Enter critical section, perform actions, then exit critical section

flag[i] = false;

Perform other non-critical section actions

Until false;

For the program to guarantee mutual exclusion, progress, and bounded waiting, the predicate P in the while loop should be:

  1. A.

    flag[j] = true and turn = i

  2. B.

    flag[j] = true and turn = j

  3. C.

    flag[i] = true and turn = j

  4. D.

    flag[i] = true and turn = i

Attempted by 236 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…