Answer: Data Hazard occurs when the execution of an instruction depends on the result of the previous instruction and that result of instruction has not been computed yet.
Data dependencies can be categorized into four types Read after Read (RAR), Write after Write (WAW), Read after Write (RAW), and Write after Read (WAR).
Four types of Data dependency in Data Hazard
The four types of data dependencies have been elucidated below:
Read after Read (RAR) hazard does not cause a problem for the processor as reading a register value does not change the register value.
Write after Write (WAW) hazard occurs when the output register of an instruction tries to write its result to the same register.
Read after Write (RAW) hazard occurs when the value produced by an instruction is required by a subsequent instruction. It is also known as true dependency or flow dependency.
Write after Read (WAR) hazard occurs when the output register of an instruction is used immediately after read by a previous instruction.
In Computer Science, Data Hazard occurs when
Data hazard occurs when exhibiting data dependence changes data in different stages of a pipeline. There are three types of hazards structural hazards, data hazards, and control hazards.