diff options
author | Tom <tomut@yahoo.com> | 2020-11-15 11:58:19 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-30 13:17:02 +0100 |
commit | 6cb640eebaf40acbd505bcfdb0dee8e99fb77223 (patch) | |
tree | 59df685d35fbc30cde064ad6a71479aadd66aeec /Kernel/Time/TimeManagement.h | |
parent | e0e26c6c679cad38c809ff3d898d135e505c67ff (diff) | |
download | serenity-6cb640eebaf40acbd505bcfdb0dee8e99fb77223.zip |
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.
Diffstat (limited to 'Kernel/Time/TimeManagement.h')
-rw-r--r-- | Kernel/Time/TimeManagement.h | 13 |
1 files changed, 11 insertions, 2 deletions
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<HardwareTimerBase*> scan_for_non_periodic_timers(); NonnullRefPtrVector<HardwareTimerBase> m_hardware_timers; void set_system_timer(HardwareTimerBase&); + static void timer_tick(const RegisterState&); + // Variables between m_update1 and m_update2 are synchronized + Atomic<u32> 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<u32> m_update2 { 0 }; + RefPtr<HardwareTimerBase> m_system_timer; RefPtr<HardwareTimerBase> m_time_keeper_timer; }; |