Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

GATE | GATE IT 2006 | Question 57

  • Last Updated : 28 Jun, 2021

The wait and signal operations of a monitor are implemented using semaphores as follows. In the following,

  • x is a condition variable,
  • mutex is a semaphore initialized to 1,
  • x_sem is a semaphore initialized to 0,
  • x_count is the number of processes waiting on semaphore x_sem, initially 0, next is a semaphore initialized to 0,
  • next_count is the number of processes waiting on semaphore next, initially 0.

    The body of each procedure that is visible outside the monitor is replaced with the following:

    Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

    Learn all GATE CS concepts with Free Live Classes on our youtube channel.




    P(mutex);
    body of procedure
    if (next_count > 0)
        V(next);
    else
        V(mutex);

    Each occurrence of x.wait is replaced with the following:




    x_count = x_count + 1;
    if (next_count > 0)
        V(next)
    else
        V(mutex);
    ------------------------------------------------------------ E1;
    x_count = x_count - 1;

    Each occurrence of x.signal is replaced with the following:




    if (x_count > 0)
    {
        next_count = next_count + 1;
        ------------------- E2;
        P(next),
        next_count = next_count - 1;
    }

    For correct implementation of the monitor, statements E1 and E2 are, respectively,
    (A) P(x_sem), V(next)
    (B) V(next), P(x_sem)
    (C) P(next), V(x_sem)
    (D) P(x_sem), V(x_sem)


    Answer: (B)

    Explanation:

    Quiz of this Question
    Please comment below if you find anything wrong in the above post




    My Personal Notes arrow_drop_up
Recommended Articles
Page :