GATE | GATE-CS-2006 | Question 42
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 address and evaluates the condition in the third stage of the pipeline. The processor stops 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:
(A) 1.0 second
(B) 1.2 seconds
(C) 1.4 seconds
(D) 1.6 seconds
Explanation: In the 3rd stage of pipeline, there will be 2 stall cycles i.e. 2 delay slots.
Total number of instructions = 109
20% out of 109 are conditional branches.
Therefore, Cycle penalty = 0.2 * 2 * 109 = 4 * 109
Clock speed is 1 GHz and each instruction on average takes 1 cycle.
Total execution time = (109 / 109) + 4 * (108 / 109)
= 1.4 seconds
Thus, total execution time of the program is 1.4 seconds.
Please comment below if you find anything wrong in the above post.
Quiz of this Question
Attention reader! Don’t stop learning now. Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.
Learn all GATE CS concepts with Free Live Classes on our youtube channel.