1
GATE CSE 2003
MCQ (Single Correct Answer)
+2
-0.6
Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S and T. The code for the processes P and Q is shown below.

Process P:

while(1){
  W:
  Print '0';
  Print '0';
  X:
}

Process Q:

while(1){
  Y:
  Print '1';
  Print '1';
  Z:
}
Synchronization statements can be inserted only at points W, X, Y, and Z.

Which of the following will always lead to an output starting with 001100110011

A
P(A) at W, V(S) at X, P(T) at Y, V(T) at Z, S and T initially 1
B
P(A) at W, V(T) at X, P(T) at Y, V(S) at Z, S initially 1 and T initially 0
C
P(S) at W, V(T) at X, P(T) at Y,V(T) at Z, S and T initially 1
D
P(S) at W, V(S) at X, P(T) at Y, V(T) at Z, S initially 1 and T initially 0
2
GATE CSE 2003
MCQ (Single Correct Answer)
+2
-0.6
Suppose we want to synchronize two concurrent processes P and Q using binary semaphores S and T. The code for the processes P and Q is shown below.

Process P:

while(1){
  W:
  Print '0';
  Print '0';
  X:
}

Process Q:

while(1){
  Y:
  Print '1';
  Print '1';
  Z:
}
Synchronization statements can be inserted only at points W, X, Y, and Z.

Which of the following will ensure that the output string never contains a substring of the form 01n0 or 10n1 where n is odd?

A
P(S) at W, V(S) at X, P(T) at Y, V(T) at Z, S and T initially 1
B
P(S) at W, V(T) at X, P(T) at Y, V(S) at Z, S and T initially 1
C
P(S) at W, V(S) at X, P(S) at Y, V(S) at Z, S initially 1
D
V(S) at W, V(T) at X, P(S) at Y, P(T) at Z, S and T initially 1
3
GATE CSE 2001
MCQ (Single Correct Answer)
+2
-0.6
Consider Peterson’s algorithm for mutual exclusion between two concurrent processes i and j. The program executed by process is shown below.
 Repeat 
     flag[i]=true; 
     turn=j; 
     while (P) do no-op; 
     Enter critical section, perform actions, then 
     exit critical section 
     Flag[i]=false; 
     Perform other non-critical section actions. 
 Until false;
For the program to guarantee mutual exclusion, the predicate P in the while loop should be
A
flag[j]=true and turn=i
B
flag[j]=true and turn=j
C
flag[i]=true and turn=j
D
flag[i]=true and turn=i
4
GATE CSE 1997
MCQ (Single Correct Answer)
+2
-0.6
Each process Pi,i=1.....9 is coded as follows

  Repeat
  P(mutex){
  critical section
  }
  V(mutex)
  Forever
The code for P10 is identical except that 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?
A
1
B
2
C
3
D
None of the above
GATE CSE Subjects
Software Engineering
Web Technologies
EXAM MAP
Medical
NEET
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
CBSE
Class 12