1
GATE CSE 2013
MCQ (Single Correct Answer)
+1
-0.3
Three concurrent processes X, Y, and Z execute three different code segments that access and update certain shared variables. Process X executes the P operation (i.e., wait) on semaphores a, b and c; process Y executes the P operation on semaphores b, c and d; process Z executes the P operation on semaphores c, d, and a before entering the respective code segments. After completing the execution of its code segment, each process invokes the V operation (i.e., signal) on its three semaphores. All semaphores are binary semaphores initialized to one. Which one of the following represents a deadlock-free order of invoking the P operations by the processes?
A
X:P(a)P(b)P(c)
Y:P(b)P(c)P(d)
Z:P(c)P(d)P(a)
B
X:P(b)P(a)P(c)
Y:P(b)P(c)P(d)
Z:P(a)P(c)P(d)
C
X:P(b)P(a)P(c)
Y:P(c)P(b)P(d)
Z:P(a)P(c)P(d)
D
X:P(a)P(b)P(c)
Y:P(c)P(b)P(d)
Z:P(c)P(d)P(a)
2
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
3
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);
}
4
GATE CSE 2013
MCQ (Single Correct Answer)
+2
-0.6
What is the return value of f (p, p), if the value of p is initialized to 5 before the call? Note that the first parameter is passed by reference, whereas the second parameter is passed by value.
int f (int &x, int c) {
    c = c - 1;
    if (c==0) return 1;
    x = x + 1;
    return f(x,c) * x;
}
A
3024
B
6561
C
55440
D
161051
EXAM MAP
Medical
NEETAIIMS
Graduate Aptitude Test in Engineering
GATE CSEGATE ECEGATE EEGATE MEGATE CEGATE PIGATE IN
Civil Services
UPSC Civil Service
Defence
NDA
Staff Selection Commission
SSC CGL Tier I
CBSE
Class 12