Process Synchronization: GATE CS Previous Year Questions

Process Synchronization · Operating System

41 questions · asked in 23 of 27 years (2000–2026)

MCQ 34 · MSQ 4 · NAT 31-mark 22 · 2-mark 19

2000Questions per year2026

Questions 21–25 of 41

Q21GATE 20102 marksMCQ−0.67 if wrong
The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0=1, S1=0, S2=0.
Process P0Process P1Process P2
while (true) {
   wait (S0);
    print ‘0’;
    release (S1);
    release (S2);
 }
wait (S1);
release (S0);
wait (S2);
release (S0);

How many times will process P0 print '0'?

Q22GATE 20101 markMCQ−0.33 if wrong
Consider the methods used by processes P1 and P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1 and S2 are randomly assigned.
Method used by P1Method used by P2
while (S1 == S2);
Critical Section
S1 = S2;
while (S1 != S2);
Critical Section
S2 = not(S1);

Which one of the following statements describes the properties achieved?

Q23GATE 20092 marksMCQ−0.67 if wrong
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 nitialized 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 is TRUE?

Q24GATE 20082 marksMCQ−0.67 if wrong
The following is a code with two threads, producer and consumer, that can run in parallel. Further, S and Q are binary semaphores quipped with the standard P and V operations.
 semaphore S = 1, Q = 0; 
integer x;

producer:                   consumer:
while (true) do             while (true) do
    P(S);                       P(Q);
    x = produce ();             consume (x);
    V(Q);                       V(S);
done                        done

Which of the following is TRUE about the program above?

Q25GATE 20082 marksMCQ−0.67 if wrong
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 PbP_{b} and VbV_{b} the wait and signal operations on binary semaphores are provided. Two binary semaphores xbx_{b} and yby_{b} 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

Keep practising

Topics in Operating System

All CS topics ›