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?

  1. A.

    It works for 3 processes only.

  2. B.

    It uses one bool type array of size 3 bool flag [3] and int variable turn.

  3. C.

    If flag[i] is true, then process Pi is ready to enter the critical section.

  4. 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.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs