Open In App

GATE | GATE-CS-2006 | Question 42

Last Updated : 19 Nov, 2018
Like Article
Like
Save
Share
Report

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


Answer: (C)

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads