Which one of the following dependencies among the register operands of different instructions can cause a data hazard in a pipelined processor?
View worked solution
Answer: B
A data hazard occurs when instructions that overlap in execution have data dependencies, and the pipeline must be stalled or bypassed to ensure correct execution.
Let's analyze the given dependencies between two instructions, (earlier) and (later):
- Read-After-Write (RAW) / True Dependency:
tries to read a register before writes to it. If reads the register before updates it, it will receive the old (incorrect) value. This is a true data dependency and causes a data hazard in almost all pipelined processors (including standard in-order pipelines).
- Write-After-Read (WAR) / Anti-Dependency:
tries to write to a register before it is read by . In a standard in-order pipeline, reads occur in an early stage (e.g., Instruction Decode) and writes occur in a late stage (e.g., Write Back), so always reads the value before overwrites it. Thus, WAR does not cause a hazard in standard in-order pipelines.
- Write-After-Write (WAW) / Output Dependency:
tries to write to a register before writes to it. In an in-order pipeline, writes happen in program order, so this does not cause a hazard.
- Read-After-Read (RAR):
Both instructions only read the register. Since no instruction modifies the register value, no hazard can ever occur.
Thus, Read-after-write (RAW) is the dependency that causes a data hazard in a pipelined processor.
Free practice · Your answers on this page are not saved.
