GATE CS 2024 Set 2 — Question 31

MSQ+1 / -0EasyData Hazards (RAW, WAR, WAW)Instruction PipeliningComputer Organization & Architecture

Computer Organization & Architecture → Instruction Pipelining → Data Hazards (RAW, WAR, WAW)

Last updated

Question

An instruction format has the following structure:
Instruction Number: Opcode destination reg, source reg-1, source reg-2
Consider the following sequence of instructions to be executed in a pipelined processor:
I1: DIV R3, R1, R2
I2: SUB R5, R3, R4
I3: ADD R3, R5, R6
I4: MUL R7, R3, R8
Which of the following statements is/are TRUE?
A.
There is a RAW dependency on R3 between I1 and I2
B.
There is a WAR dependency on R3 between I1 and I3
C.
There is a RAW dependency on R3 between I2 and I3
D.
There is a WAW dependency on R3 between I3 and I4

Correct answer

(A) There is a RAW dependency on R3 between I1 and I2

Solution

Let's analyze the dependencies based on the instruction format: Opcode dest, src1, src2.
Instructions:
  • I1: DIV R3, R1, R2 \rightarrow Writes R3R3, Reads R1,R2R1, R2
  • I2: SUB R5, R3, R4 \rightarrow Writes R5R5, Reads R3,R4R3, R4
  • I3: ADD R3, R5, R6 \rightarrow Writes R3R3, Reads R5,R6R5, R6
  • I4: MUL R7, R3, R8 \rightarrow Writes R7R7, Reads R3,R8R3, R8
Analysis of Options:
(A) RAW dependency on R3 between I1 and I2:
  • I1 writes R3R3.
  • I2 reads R3R3.
  • Since I2 follows I1 and reads the value written by I1, this is a RAW (Read-After-Write) dependency.
  • This statement is TRUE.
(B) WAR dependency on R3 between I1 and I3:
  • I1 writes R3R3.
  • I3 writes R3R3.
  • This is a WAW (Write-After-Write) dependency (Output dependency), not WAR.
  • This statement is FALSE.
(C) RAW dependency on R3 between I2 and I3:
  • I2 reads R3R3.
  • I3 writes R3R3.
  • This is a WAR (Write-After-Read) dependency (Anti-dependency), not RAW.
  • This statement is FALSE.
(D) WAW dependency on R3 between I3 and I4:
  • I3 writes R3R3.
  • I4 reads R3R3.
  • This is a RAW (Read-After-Write) dependency, not WAW.
  • This statement is FALSE.
Thus, only option (A) is correct.

More questions on Instruction Pipelining

Practice GATE CS PYQs with adaptive difficulty

Timed practice, skill tracking, and AI explanations — free to start.

Start practicing free