Question 31
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? (A)
ExitX(R, S) { P(R); V(S); } EntryY (R, S) { P(S); V(R); }(B)
ExitX(R, S) { V(R); V(S); } EntryY(R, S) { P(R); P(S); }(C)
ExitX(R, S) { P(S); V(R); } EntryY(R, S) { V(S); P(R); }(D)
ExitX(R, S) { V(R); P(S); } EntryY(R, S) { V(S); P(R); }
Question 32
X -> c.X, c/d X -> .cX, c/d X -> .d, c/d X -> c.X, $ X -> .cX, $ X -> .d, $Which of the following statements related to merging of the two sets in the corresponding LALR parser is/are FALSE?
Question 34
int f(int &x, int c) {
c = c - 1;
if (c==0) return 1;
x = x + 1;
return f(x,c) * x;
}
Question 35
Question 37
Consider an instruction pipeline with five stages without any branch prediction: Fetch Instruction (FI), Decode Instruction (DI), Fetch Operand (FO), Execute Instruction (EI) and Write Operand (WO). The stage delays for FI, DI, FO, EI and WO are 5 ns, 7 ns, 10 ns, 8 ns and 6 ns, respectively. There are intermediate storage buffers after each stage and the delay of each buffer is 1 ns. A program consisting of 12 instructions I1, I2, I3, …, I12 is executed in this pipelined processor. Instruction I4 is the only branch instruction and its branch target is I9. If the branch is taken during the execution of this program, the time (in ns) needed to complete the program is
Question 38
Question 40
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?
There are 58 questions to complete.