native_clock: Re-adjust the RDTSC frequency

The RDTSC frequency reported by CPUID is not accurate to its true frequency.
We will spawn a separate thread to calculate the true RDTSC frequency after a measurement period of 30 seconds has elapsed.
This commit is contained in:
Morph 2023-03-04 21:44:31 -05:00
parent a7792e5ff8
commit dcd13a7566
2 changed files with 34 additions and 5 deletions

View file

@ -3,6 +3,7 @@
#pragma once
#include "common/polyfill_thread.h"
#include "common/wall_clock.h"
namespace Common {
@ -28,6 +29,8 @@ public:
private:
u64 GetRTSC();
void CalculateAndSetFactors();
union alignas(16) TimePoint {
TimePoint() : pack{} {}
u128 pack{};
@ -47,6 +50,8 @@ private:
u64 ms_rtsc_factor{};
u64 rtsc_frequency;
std::jthread time_sync_thread;
};
} // namespace X64