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?
- A.
1
- B.
2
- C.
3
- 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:
flag[2]→ an array of 2 boolean variables to indicate whether a process wants to enter the critical section.turn→ an integer variable to decide whose turn it is.
So, total variables used = 2 flag variables + 1 turn variable = 3 variables.