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 11–15 of 41

Q11GATE 2016 (Session 1)2 marksMCQ−0.67 if wrong
Consider the following proposed solution for the critical section problem. There are n processes: P0...Pn−1P_{0}...P_{n-1} . In the code,function pmaxpmax returns an integer not smaller than any of its arguments. For all i, t[i] is initialized to zero.
Code for Pi:
do {
    c[i]=1; t[i] = pmax(t[0],...,t[n-1])+1; c[i]=0;
    for every j ≠ i in {0,...,n-1} {
        while (c[j]);
        while (t[j] != 0 && t[j]<=t[i]);
    }
    Critical Section;
    t[i]=0;
    Remainder Section;
} while (true);

Which one of the following is TRUE about the above solution?

Q12GATE 2016 (Session 2)2 marksMCQ−0.67 if wrong
Consider the following two-process synchronization solution.

Process 0                               Process 1
---------                               ----------
Entry: loop while (turn == 1);          Entry: loop while (turn == 0);
  (critical section)                      (critical section)
Exit:  turn = 1;                        Exit:  turn = 0;

The shared variable turn is initialized to zero.Which one of the following is TRUE?

Q13GATE 2016 (Session 2)2 marksNAT
Consider a non-negative counting semaphore S. The operation P(S) decrements S, and V(S) increments S. During an execution, 20 P(S) operations and 12V(S) operations are issued in some order. The largest initial value of S for which at least one P(S) operation will remain blocked is ________.

Q14GATE 2015 (Session 1)1 markNAT
The following two functions P1 and P2 that share a variable B with an initial value of 2 execute concurrently.
P1( ) {                 P2( ) {
    C = B - 1;              D = 2 * B;
    B = 2 * C;              B = D - 1;
}                       }

The number of distinct values that B can possibly take after the execution is______________.

Q15GATE 2015 (Session 3)1 markMCQ−0.33 if wrong
Two processes X and Y need to access a critical section. Consider the following synchronization construct used by both the processes
Process X                         Process Y

/* other code for process X */    /* other code for process Y */
while(true)                       while(true)
{                                 {
   varP = true;                      varQ = true;
   while(varQ == true)               while(varP == true)
        {                                 {
       /* Critical  Section  */          /* Critical  Section  */
              varP =  false;                    varQ =  false;
         }                                 }
}                                 }
/* other code for process X */    /* other code for process Y */

Here, varP and varQ are shared variables and both are initialized to false. Which one of the following statements is true?

Keep practising

Topics in Operating System

All CS topics ›