A CPU has a 3-stage pipeline: IF, ID, EX. If the EX stage takes 2 cycles, what is the total number of cycles to execute 5 instructions?
Q1. A CPU has a 3-stage pipeline: IF, ID, EX. If the EX stage takes 2 cycles, what is the total number of cycles to execute 5 instructions?
Answer: 7
Explanation: For the first instruction, it takes 3 + 1 (for EX) = 4 cycles. For subsequent 4 instructions, it takes 1 cycle each, so total cycles = 4 + 4 - 1 (since the pipeline is filled) = 7.