From 6cb640eebaf40acbd505bcfdb0dee8e99fb77223 Mon Sep 17 00:00:00 2001 From: Tom Date: Sun, 15 Nov 2020 11:58:19 -0700 Subject: Kernel: Move some time related code from Scheduler into TimeManagement Use the TimerQueue to expire blocking operations, which is one less thing the Scheduler needs to check on every iteration. Also, add a BlockTimeout class that will automatically handle relative or absolute timeouts as well as overriding timeouts (e.g. socket timeouts) more consistently. Also, rework the TimerQueue class to be able to fire events from any processor, which requires Timer to be RefCounted. Also allow creating id-less timers for use by blocking operations. --- Kernel/Time/TimeManagement.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Kernel/Time/TimeManagement.h') diff --git a/Kernel/Time/TimeManagement.h b/Kernel/Time/TimeManagement.h index b6c268e3af..b70b162fc7 100644 --- a/Kernel/Time/TimeManagement.h +++ b/Kernel/Time/TimeManagement.h @@ -46,11 +46,13 @@ public: static void initialize(u32 cpu); static TimeManagement& the(); + static timespec ticks_to_time(u64 ticks, time_t ticks_per_second); + static u64 time_to_ticks(const timespec& tspec, time_t ticks_per_second); + + timespec monotonic_time() const; 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; time_t boot_time() const; bool is_system_timer(const HardwareTimerBase&) const; @@ -60,6 +62,8 @@ public: static bool is_hpet_periodic_mode_allowed(); + u64 uptime_ms() const; + u64 monotonic_ticks() const; static timeval now_as_timeval(); timespec remaining_epoch_time_adjustment() const { return m_remaining_epoch_time_adjustment; } @@ -72,11 +76,16 @@ private: Vector scan_for_non_periodic_timers(); NonnullRefPtrVector m_hardware_timers; void set_system_timer(HardwareTimerBase&); + static void timer_tick(const RegisterState&); + // Variables between m_update1 and m_update2 are synchronized + Atomic m_update1 { 0 }; u32 m_ticks_this_second { 0 }; u32 m_seconds_since_boot { 0 }; timespec m_epoch_time { 0, 0 }; timespec m_remaining_epoch_time_adjustment { 0, 0 }; + Atomic m_update2 { 0 }; + RefPtr m_system_timer; RefPtr m_time_keeper_timer; }; -- cgit v1.2.3