Time Left - 10:00 mins

GATE 2020 : Operating System Quiz 6

Attempt now to get your rank among 604 students!

Question 1

We have a counting semaphore which is initialized to 9. We have performed 26P and 25V Operations are performed. Then the final value of semaphore is______ .

Question 2

Consider two processes P0 and P1 which shares a global variable ‘flag’. The value of flag is either 0 or 1 where 0 indicates “P0 is permitted to enter the critical-section” and 1 indicates for P1. Assume P0(i=0) and P1(i=1) are concurrent processes which are executing the following code with initial value of flag as 0.
while (1)
{
while( flag!=1);
<critical section>
flag = i-1;
<remainder section>
}
If P0 starts executing first, which of the following holds by the above execution.

Question 3

Solution to Critical Section problem includes mutual exclusion, progress and bounded waiting between two processes. To provide better synchronization between process there is synchronization in hardware, then choose the false among the following in context to hardware.

Question 4

The enter_cs ( ) and leave_CS ( ) functions to implement critical section of a process are realized using test-and-set instruction as follows:
void enter_CS(X)
{
while (test-and-set(X));
}

void leave_CS(X)
{
X=0 ;
}
In the above solution, X is a memory location associated with the CS and is initialized to 0. Now consider the following statements:
I. The above solution to CS problem is deadlock-free.
II. The solution is starvation free.
III. The processes enter CS in FIFO order.
IV. More than one process can enter CS at the same time.
Which of the above statements are TRUE?

Question 5

Consider the following code to solve the critical section problem for two processes P0 and P1. Initially flag [i] contain false for i=0 and 1
While (1)
{
Flag [i] =true;
While (flag[j]);
<critical section>
flag [i] = false;
<remainder section>
}
Assume i refers to the current process Pi and j refers the other process Pj. If two processes executing above code concurrently then which of the following does not satisfy the above solution?

Question 6

The P and V operations on counting semaphores, where s is a counting semaphore, are defined as follows:
P(s):  s = s - 1;
         if s < 0 then wait;
V(s): s = s + 1;
         if s <= 0 then wakeup a process waiting on s;
Assume that Pb and Vb, the wait and signal operations on bi nary semaphores are provided. Two binary semaphores Xb and Yb are used to implement the semaphore operations P(s) and V(s) as follows:
P(S) :
       Pb (Xb) ;
       s = s - 1;
       if (s < 0) {
         Vb (Xb);
         Pb (Yb);
       }
       else Vb (Xb);
V(s):
      Pb(Xb);
      s = s + 1;
      if (s <= 0) Vb(Yb);
      Vb (Xb);
The initial values of Xb and Yb are respectively
  • 604 attempts
  • 4 upvotes
  • 4 comments
Jun 25GATE & PSU CS