1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-03 05:22:08 +00:00

Kernel: Take into account the time keeper's frequency (if no HPET)

The PIT is now also running at a rate of ~250 ticks/second, so rather
than assuming there are 1000 ticks/second we need to query the timer
being used for the actual frequency.

Fixes #4508
This commit is contained in:
Tom 2020-12-26 17:09:54 -07:00 committed by Andreas Kling
parent 0e2b7f9c9a
commit f1534ff36e
2 changed files with 7 additions and 3 deletions

View file

@ -366,9 +366,8 @@ void TimeManagement::increment_time_since_boot()
// Compute time adjustment for adjtime. Let the clock run up to 1% fast or slow.
// That way, adjtime can adjust up to 36 seconds per hour, without time getting very jumpy.
// Once we have a smarter NTP service that also adjusts the frequency instead of just slewing time, maybe we can lower this.
constexpr long NanosPerTick = 1'000'000; // FIXME: Don't assume that one tick is 1 ms.
constexpr time_t MaxSlewNanos = NanosPerTick / 100;
static_assert(MaxSlewNanos < NanosPerTick);
long NanosPerTick = 1'000'000'000 / m_time_keeper_timer->frequency();
time_t MaxSlewNanos = NanosPerTick / 100;
u32 update_iteration = m_update1.fetch_add(1, AK::MemoryOrder::memory_order_acquire);