Which of the following statements is correct about Peterson's algorithm for…
2022
Which of the following statements is correct about Peterson's algorithm for process synchronisation?
- A.
It works for 3 processes only.
- B.
It uses one bool type array of size 3 bool flag [3] and int variable turn.
- C.
If flag[i] is true, then process Pi is ready to enter the critical section.
- D.
It fails when two processes want to enter the critical section at the same time.
Attempted by 195 students.
Show answer & explanation
Correct answer: C
Peterson's algorithm is specifically designed for synchronizing exactly two processes. It uses a flag array of size 2, where flag[i] being true indicates process i is ready to enter the critical section. This mechanism ensures mutual exclusion, preventing simultaneous access by both processes.