-1
\$\begingroup\$

As the title suggests, I want to understand the difference. Attaching the reference. context

\$\endgroup\$
10
  • 3
    \$\begingroup\$ A stall, as in having to wait for something, for example data that has to be brought in from main memory because it was not in cache (cache miss). A flush, having to clear everything that was already being worked on in the pipeline, throwing away all the work that was already done. For example because of a failed branch prediction. \$\endgroup\$ Aug 10, 2021 at 16:27
  • 4
    \$\begingroup\$ So what do you understand about stalls and flushing? \$\endgroup\$ Aug 10, 2021 at 16:29
  • 7
    \$\begingroup\$ I feel as though this is one of those rare questions which, if you have to ask it, can't be answered well. If you know enough to absorb a reasonably-sized answer, then you already know enough to answer your own question. If you don't know enough, then it would take too long to write anything useful because so much ground-work is required to pull you forward enough that you will finally be able to understand the direct answer taking up only a small, last paragraph. You've clearly got a book. I'd say, read it and think closely about each part leading up to this part. \$\endgroup\$
    – jonk
    Aug 10, 2021 at 16:34
  • 3
    \$\begingroup\$ No, stalling is waiting on something before continueing where you left off. Flushing is throwing away what you've already done. \$\endgroup\$ Aug 10, 2021 at 17:54
  • 6
    \$\begingroup\$ @Anonymus Please provide a source reference for the image. \$\endgroup\$
    – Voltage Spike
    Aug 10, 2021 at 18:14

3 Answers 3

6
\$\begingroup\$

Think of a car production line - at each stage a component is added to the car. At a stage in the production line, the person has run out of parts. The production line is ‘stalled’ - no further work can be done until that stage has parts again. In the case of the processor, it might be waiting for a memory access to complete. This stops other potential work being done.

With the same production line concept it is determined no one is buying the cars. There are two choices, finish the cars that are on the production line and throw them away or cut your losses and just clear out all the unfinished cars and dump them - this is a ‘flush’. In the case of the processor, this might be a jump instruction. All the work that was following that instruction is wasted. The processor will jump to a new location and begin to fill up the pipeline again.

Either a stall or a flush hurts performance as potential clock cycles do not yield useful work. Whether it be a car production line or a pipelined processor, a stall or flush is something you want to avoid, so you devise strategies for this.

\$\endgroup\$
3
\$\begingroup\$

Pipeline stalling:

Suppose there's a data dependency in the pipeline, i.e. an instruction needs data from the result of a previous instruction. So you need to stall this instruction till the previous one completes to resolve the data hazard. Stalling is done by inserting "No Ops" i.e. instructions that do no work. This keeps the processor idle and decreases the throughput.

Pipeline flushing:

Suppose there's a conditional branch instruction in the program. This instruction is moving forward in the pipeline. If it's a 5 stage classic RISC pipeline, let's suppose this instruction reaches the 3rd stage.

The stages of the pipeline behind this instruction are executing the instructions following the branch statement. Depending on the outcome of the execution of the branch statement, the instructions after the branch are either executed as required by the program i.e. the branch is not taken so they have to be executed, or are executed even though they are not required by the program i.e. the branch is taken so they do not have to be executed.

In the second case, you are executing instructions that were not required by the program, so you need to flush the pipeline to remove the wrong data in the pipeline stages. This reduces the throughput.


Pipeline stalling and flushing can be reduced using Out-of-Order execution and branch prediction algorithms.

Data hazards which cause pipeline stalling can also be dealt using pipeline forwarding.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ I think you should rather suppose the branch instruction is in the 3rd/4th stage because that's where usually the branch control is on a 5-stage pipeline. So that the next two/three instructions are now be flushed off. \$\endgroup\$
    – Mitu Raj
    Aug 13, 2021 at 9:49
  • 2
    \$\begingroup\$ @MituRaj yes, I agree, I have modified it to be the 3rd stage. Thanks \$\endgroup\$ Aug 13, 2021 at 11:24
0
\$\begingroup\$

You need a book before you can proceed with your project; so you order it from Amazon.

  1. Amazon will deliver it tomorrow; until the postman arrives tomorrow, there is nothing you can do. This is a stall.

  2. Amazon is out of stock. Until it is re-printed, all you can do is put that project aside, (commit everything you have done so far) and start a new project. This is a flush.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.