Two processes, P_1 and P_2, need to access a critical section of code.…

2007

Two processes, P_1 and P_2, need to access a critical section of code. Consider the following synchronization construct used by the processes: Here, wants1 and wants2 are shared variables, which are initialized to false. Which one of the following statements is TRUE about the above construct?

P1​(i)

P2​(j)

While(true)

While(true)

{

{

wants1 = T;

wants2 = T;

While (wants2 == T);

While (wants1 == T);

Critical section

Critical section

wants1 = F;

wants2 = F;

Remainder section

Remainder section

}

}

  1. A.

    It does not ensure mutual exclusion.

  2. B.

    It does not ensure bounded waiting.

  3. C.

    It requires that processes enter the critical section in strict alternation.

  4. D.

    It does not prevent deadlocks, but ensures mutual exclusion

Attempted by 103 students.

Show answer & explanation

Correct answer: D

This synchronization construct lacks a turn variable, which is essential for progress in Peterson's algorithm. While mutual exclusion holds because processes check the other's flag, setting both flags to true simultaneously causes indefinite waiting. Consequently, this algorithm suffers from deadlock and does not guarantee progress.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir