ELI5: Explain Like I'm 5

Hazard (computer architecture)

When we use a computer, we want it to work perfectly all the time. However, sometimes something unexpected can happen and cause the computer to not work as we want it to. This unexpected thing is called a hazard.

Hazard in computer architecture can be explained by thinking about a race. Imagine a race where three runners, A, B, and C, are running. Runner A is running the entire race, whereas runner B and C are running half the distance.

Now, when runner A reaches the finish line, runner B and C are still running. But if we only look at the finish time of runner A, we might not realize that they had a disadvantage because runner B and C were still running.

This is what happens in computer architecture as well. When certain instructions are executed, there might be a situation where another instruction needs to wait for the first one to finish before executing. This waiting can cause a delay that slows down the performance of the computer.

To avoid hazards, computer architects develop techniques. For example, they can add a hardware component called a forwarding unit. The forwarding unit checks if there are any potential hazards, and if so, it resolves them by forwarding data to the dependent instruction.

Another technique computer architects use is called pipelining. Pipelining means breaking down the processing of an instruction into multiple stages to optimize performance.

In summary, a hazard is like a speed bump that slows down the computer. Computer architects develop techniques to avoid hazards and optimize computer performance.