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 |
|
|
|
Enter critical section, perform actions, then exit critical section |
|
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:
- 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 236 students.
Sign up free to check your answer
Sign up freeLoading lesson…