Open In App
Related Articles

GATE | GATE-CS-2001 | Question 47

Improve Article
Improve
Save Article
Save
Like Article
Like

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

   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, 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


Answer: (B)

Explanation: See question 2 of https://www.geeksforgeeks.org/operating-systems-set-2/

Quiz of this Question

Level Up Your GATE Prep!
Embark on a transformative journey towards GATE success by choosing Data Science & AI as your second paper choice with our specialized course. If you find yourself lost in the vast landscape of the GATE syllabus, our program is the compass you need.

Last Updated : 28 Jun, 2021
Like Article
Save Article
Previous
Next
Similar Reads