1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:17:36 +00:00

Kernel: Let TimeManagement keep epoch time as timespec

Previously, it was kept as just a time_t and the sub-second
offset was inferred from the monotonic clock. This means that
sub-second time adjustments were ignored.

Now that `ntpquery -s` can pass in a time with sub-second
precision, it makes sense to keep time at that granularity
in the kernel.

After this, `ntpquery -s` immediately followed by `ntpquery` shows
an offset of 0.02s (that is, on the order of network roundtrip time)
instead of up to 0.75s previously.
This commit is contained in:
Nico Weber 2020-09-06 19:52:24 -04:00 committed by Andreas Kling
parent 4ac5cc2461
commit e8131f503d
3 changed files with 22 additions and 15 deletions

View file

@ -47,8 +47,8 @@ public:
static void initialize();
static TimeManagement& the();
time_t epoch_time() const;
void set_epoch_time(time_t);
timespec epoch_time() const;
void set_epoch_time(timespec);
time_t seconds_since_boot() const;
time_t ticks_per_second() const;
time_t ticks_this_second() const;
@ -72,7 +72,7 @@ private:
u32 m_ticks_this_second { 0 };
u32 m_seconds_since_boot { 0 };
time_t m_epoch_time { 0 };
timespec m_epoch_time { 0, 0 };
RefPtr<HardwareTimer> m_system_timer;
RefPtr<HardwareTimer> m_time_keeper_timer;
};