How many variables are used in Peterson's algorithm for synchronisation of two…

2022

How many variables are used in Peterson's algorithm for synchronisation of two processes?

  1. A.

    1

  2. B.

    2

  3. C.

    3

  4. D.

    4

Attempted by 279 students.

Show answer & explanation

Correct answer: C

Peterson's algorithm for two processes utilizes three shared variables. These are two flag arrays indicating process intent and a single turn variable to manage access.

Peterson’s Algorithm for synchronization of two processes uses 3 shared variables:

  1. flag[2] → an array of 2 boolean variables to indicate whether a process wants to enter the critical section.

  2. turn → an integer variable to decide whose turn it is.

So, total variables used = 2 flag variables + 1 turn variable = 3 variables.

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs