This function is called by the timer interrupt handler
()
| 34 | |
| 35 | /// This function is called by the timer interrupt handler |
| 36 | pub fn pit_interrupt_notify() { |
| 37 | // Increment the number of PIT ticks |
| 38 | PIT_TICKS.fetch_add(PIT_TICKS_PER_INTERRUPT, Ordering::Relaxed); |
| 39 | |
| 40 | // Get the change in TSC from last time, and update moving average of |
| 41 | // TSC ticks per PIT tick. |
| 42 | let new_tsc = time_stamp_counter(); |
| 43 | let last_tsc = LAST_TSC.swap(new_tsc, Ordering::Relaxed); |
| 44 | let new_tsc_per_pit = (new_tsc - last_tsc) / PIT_TICKS_PER_INTERRUPT; |
| 45 | let ma_tsc_per_pit = (new_tsc_per_pit + TSC_PER_PIT.load(Ordering::Relaxed)) / 2; |
| 46 | TSC_PER_PIT.store(ma_tsc_per_pit, Ordering::Relaxed); |
| 47 | |
| 48 | // Store in user-accessible KernelInfo page |
| 49 | let info = memory::kernel_info::get_mut(); |
| 50 | info.pit_ticks = PIT_TICKS.load(Ordering::Relaxed); |
| 51 | info.last_tsc = new_tsc; |
| 52 | info.tsc_per_pit = ma_tsc_per_pit; |
| 53 | } |
| 54 | |
| 55 | /// Monotonic count of he number of microseconds since restart |
| 56 | /// |
no test coverage detected