-
A CPU has a five-stage pipeline and runs at 1 GHz frequency. Instruction fetch happens in the first stage of the pipeline. A conditional branch instruction computes the target addresses and evaluates the condition in the third stage of the pipeline. The processor stop fetching new instructions following a conditional branch until the branch outcome is known. A program executes 109 instructions out of which 20% are conditional branches. If each instruction takes one cycle to complete on average, the total execution time of the program is
-
- 1.0 s
- 1.2 s
- 1.4 s
- 1.6 s
- 1.0 s
Correct Option: C
In the 3rd stage of pipeline, there will be 2 shall cycles.
Total number of instructions = 109, 20% out of 109 are conditional branches. Therefore, cycle penalty = 0.2 * 2 * 109 = 4 * 108.
Clock speed is 1GHz and each instruction on average takes 1 cycle. so
Total execution time = | + 4* | |||||||
109 | 109 |
= 1 + (0.4) = 1.4 sec