GATE 2013 Computer Science and Information Technology (CS) Questions with Solutions

GATE 2013

80 questions

MCQ 801-mark 38 · 2-mark 42

Questions 41–45 of 80

Q41Intermediate Code Generation2 marksMCQ−0.67 if wrong
The following code segment is executed on a processor which allows only register operands in its instructions. Each instruction can have atmost two source operands and one destination operand. Assume that all variables are dead after this code segment.
c = a + b;
d = c * a;
e = c + a;
x = c * c;
if (x > a) {
   y = a * a;
}
else {
   d = d * d;
   e = e * e;
} 
Suppose the instruction set architecture of the processor has only two registers. The only allowed compiler optimization is code motion, which moves statements from one place to another while preserving correctness. What is the minimum number of spills to memory in the compiled code?

Q42Process Synchronization2 marksMCQ−0.67 if wrong
A certain computation generates two arrays a and b such that a[i]=f(i)for o≤i<no\leq i \lt n and b[i] = g (a[i] )for o≤i<no\leq i \lt 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;                    Process Y;
private i;                    private i;
for (i = 0; i < n; i ++) {    for (i = 0; i < n; i ++) {
   a[i] = f(i);                  EntryY(R, S);
   ExitX(R, S);                  b[i] = g(a[i]);
}                             }

Which one of the following represents the CORRECT implementations of ExitX and EntryY?

Q43Process Synchronization2 marksMCQ−0.67 if wrong
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?

Q44Process Synchronization1 markMCQ−0.33 if wrong
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?

Q45CPU Scheduling1 markMCQ−0.33 if wrong
A scheduling algorithm assigns priority proportional to the waiting time of a process. Every process starts with priority zero (the lowest priority). The scheduler re-evaluates the process priorities every T time units and decides the next process to schedule. Which one of the following is TRUE if the processes have no I/O operations and all arrive at time zero?