title: How to determine misprediction penalty?(CPU pipeline)
body: <p>I was reading a textbook which says:</p>
  <p><strong>Assume the probability of misprediction is p, the time to execute the code without misprediction is T<sub>OK</sub> and the misprediction penalty is T<sub>MP</sub>. Then the average time to execute the code as a function of p is:</strong></p>
  <p><strong>T<sub>avg</sub>(p) =  (1− p)T<sub>OK</sub> + p(T<sub>OK</sub> + T<sub>MP</sub>)</strong></p>
  <p>I'm a little bit confused, isn't it should be:</p>
  <p>T<sub>avg</sub>(p) =  (1− p)T<sub>OK</sub> + pT<sub>MP</sub></p>
  <p>for example, let's say p is 0.5, it takes 10 clock cycles for cpu when branch prediction is correct and it takes 20 clock cycles for cpu when branch prediction is incorrect, isn't the average clock cycles is 0.5(10+20) = 15 clock cycles?</p>