Skip to content
Official PYQ · 1997

GATE CS 1997 Q6.8 — Concurrency and Synchronization

Explain with AI

Each Process Pi,i=1…9P_i, i = 1\ldots 9 is coded as follows

repeat 
    P(mutex)
    {Critical section}
    V(mutex)
forever

The code for P10P_{10} is identical except it uses V(mutex) in place of P(mutex). What is the largest number of processes that can be inside the critical section at any moment?

Choose one option
View worked solution

Answer: D

Let us analyze the behavior of the processes. Typically, a semaphore mutex used for mutual exclusion is initialized to 11.

For processes P1P_1 to P9P_9, the code is:

repeat 
    P(mutex)
    {Critical Section}
    V(mutex)
forever

For process P10P_{10}, replacing the entry P(mutex) with V(mutex) gives:

repeat 
    V(mutex)
    {Critical Section}
    V(mutex)
forever

Step-by-Step Execution Trace:

  1. Initially, mutex = 1.
  2. Process P10P_{10} executes its entry operation V(mutex). Since V is an increment operation, mutex becomes 22. P10P_{10} enters the critical section.
  3. Inside the loop, P10P_{10} can execute V(mutex) again at the exit, making mutex = 3.
  4. Since P10P_{10} does not have any blocking P(mutex) operation, it can loop repeatedly, executing V(mutex) each time and increasing the value of mutex arbitrarily high (e.g., 1010 or more).
  5. With mutex ≥ 9, all other nine processes (P1P_1 to P9P_9) can execute their P(mutex) operations without blocking and enter the critical section simultaneously.

Thus, all 1010 processes can be inside the critical section at the same time. Since 1010 is not listed in options A, B, or C, the correct option is D (None of the above).

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Concurrency and Synchronization questions