1
GATE CSE 2013
MCQ (Single Correct Answer)
+2
-0.6
A shared variable x, initialized to zero, is operated on by four concurrent processes W, X, Y, Z as follows. Each of the processes W and X reads x from memory, increments by one, stores it to memory, and then terminates. Each of the processes Y and Z reads x from memory, decrements by two, stores it to memory, and then terminates. Each process before reading x invokes the P operation (i.e., wait) on a counting semaphore S and invokes the V operation (i.e., signal) on the semaphore S after storing x to memory. Semaphore S is initialized to two. What is the maximum possible value of x after all processes complete execution?
A
-2
B
-1
C
1
D
2
2
GATE CSE 2013
MCQ (Single Correct Answer)
+2
-0.6
A certain computation generates two arrays a and b such that a[i]=f(i)for 0 ≤ i < n and b[i] = g (a[i] )for 0 ≤ i < n. Suppose this computation is decomposed into two concurrent processes X and Y such that X computes the array a and Y computes the array b. The processes employ two binary semaphores R and S, both initialized to zero. The array a is shared by the two processes. The structures of the processes are shown below.
Process X:
private i;
for(i = 0; i < n; i++){
 a [i] = f (i);
 Exit X (R, S);
}

Process Y:
private i;
for(i = 0; i < n; i++){
 Entry Y (R, S);
 b [i] = g (a [i] );
}
Which of the following represents the correct implementations of Exit X and Entry Y?
A
Exit X (R, S){
  P(R);
  V(S);
}
Entry Y (R, S){
  P(S);
  V(R);
}
B
Exit X (R, S){
  V(R);
  V(S);
}
Entry Y (R, S){
  P(R);
  P(S);
}
C
Exit X (R, S){
  P(S);
  V(R);
}
Entry Y (R, S){
  V(S);
  P(R);
}
D
Exit X (R, S){
  V(R);
  P(S);
}
Entry Y (R, S){
  V(S);
  P(R);
}
3
GATE CSE 2012
MCQ (Single Correct Answer)
+2
-0.6
Fetch_And_Add (X, i) is an atomic Read-Modify-Write instruction that reads the value of memory location X, increments it by the value i, and returns the old value of X. It is used in the pseudocode shown below to implement a busy-wait lock. L is an unsigned integer shared variable initialized to 0. The value of 0 corresponds to lock being available, while any non-zero value corresponds to the lock being not available.
AcquireLock(L){ 
  While (Fetch_And_Add(L,1)) 
  L = 1; 
} 
Release Lock(L){ 
  L = 0; 
}
This implementation
A
fails as L can overflow
B
fails as L can take on a non-zero value when the lock is actually available
C
works correctly but may starve some processes
D
works correctly without starvation
4
GATE CSE 2010
MCQ (Single Correct Answer)
+2
-0.6
The following program consists of 3 concurrent processes and 3 binary semaphores. The semaphores are initialized as S0=1, S1=0, S2=0. GATE CSE 2010 Operating Systems - Synchronization and Concurrency Question 9 English How many times will process P0 print '0'?
A
At least twice
B
Exaclty twice
C
Exactly thrice
D
Exactly once
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