Multiple choice

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

For the program to guarantee mutual exclusion, the predicate P in the while loop should be

  1. flag [j]= true and turn =j

  2. flag [j]=true and turn =j

  3. flag [i]=true and turn=j

  4. flag [i]=true and turn=i

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

While loop if true predicate then the program enters into critical region. This program enters into critical region of flag [i]=true act as semaphore, & true =j, the requirement of resource is by some other process.