mirror of
https://github.com/SerenityOS/serenity.git
synced 2026-11-07 12:38:38 -10:00
As it requires MMIO access, reading the raw value of the HPET timer is quite expensive, so doing it every time the system timer fired (~4ms) resulted in a heavy overload over the system. As shown in [1] it is quite known that HPET timers are slow to read. Moreover, when using QEMU reading from MMIO causes a VM exit and makes the whole virtualized world stop. The consequence is that reading the HPET timer would not appear in profiles as it is not slow from the perspective of the VM. To solve that issue, we're now using the Time Stamp Counter (TSC) as our time-keeping source. Whenever the system interrupt fires, we read the TSC (which is cheap, see [1], and doesn't cause a VM exit) and compute the elapsed time based on how many cycle the CPU made during that time. [1] https://docs.redhat.com/en/documentation/red_hat_enterprise_linux_for_real_time/7/html/reference_guide/chap-timestamping#Reading_hardware_clock_sources