GATE Computer ScienceHardGATE CS

Six instructions execute in program order: I1: LW R1, 0(R2) I2: ADD R3, R1, R4 I3: SUB R4, R3, R2 I4: SW R3, 4(R1) I5: AND R1, R4, R3 I6: OR R2, R1, R3 (The first register of LW, ADD, SUB, AND and OR is the destination; SW writes memory only.) Count every ordered pair of instructions i < j (adjacent or not, and regardless of any write in between) that has a RAW, WAR or WAW register dependence. What is the triple (RAW, WAR, WAW)?

  1. A. (9, 4, 1)
  2. B. (8, 5, 1)
  3. C. (9, 5, 1)
  4. D. (9, 5, 2)

Correct answer: C. (9, 5, 1)

RAW: R1 written by I1 is read by I2, I4, I6 (3); R3 by I2 is read by I3, I4, I5, I6 (4); R4 by I3 is read by I5 (1); R1 by I5 is read by I6 (1): total 9. WAR: I3 overwrites R4 read by I2 (1); I5 overwrites R1 read by I2 and I4 (2); I6 overwrites R2 read by I1 and I3 (2): total 5. WAW: only R1 (I1 and I5): 1.

More Computer Organization and Architecture questions

Exams that ask this topic