From f6eb155167e8bca9fba9cddb88b39ab7b049ff5d Mon Sep 17 00:00:00 2001 From: Humberto Alves Date: Mon, 20 Feb 2023 21:06:29 +0000 Subject: [PATCH] Kernel: Support more clocks in sys$clock_getres() Support all the available clocks in clock_getres(). Also, fix this function to use the actual ticks per second value, not the constant `_SC_CLK_TCK` (which is always equal to 8) and move the resolution computation logic to TimeManagement. --- Kernel/Syscalls/clock.cpp | 15 +++++---------- Kernel/Time/TimeManagement.cpp | 6 ++++++ Kernel/Time/TimeManagement.h | 1 + 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Kernel/Syscalls/clock.cpp b/Kernel/Syscalls/clock.cpp index 0f0f5d4d7e..8dc4571e71 100644 --- a/Kernel/Syscalls/clock.cpp +++ b/Kernel/Syscalls/clock.cpp @@ -98,16 +98,11 @@ ErrorOr Process::sys$clock_getres(Userspaceticks_per_second(); + return Time::from_nanoseconds(nanoseconds_per_tick); +} + UNMAP_AFTER_INIT TimeManagement::TimeManagement() : m_time_page_region(MM.allocate_kernel_region(PAGE_SIZE, "Time page"sv, Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow).release_value_but_fixme_should_propagate_errors()) { diff --git a/Kernel/Time/TimeManagement.h b/Kernel/Time/TimeManagement.h index c0371c6d35..4346f16925 100644 --- a/Kernel/Time/TimeManagement.h +++ b/Kernel/Time/TimeManagement.h @@ -52,6 +52,7 @@ public: void set_epoch_time(Time); time_t ticks_per_second() const; static Time boot_time(); + Time clock_resolution() const; bool is_system_timer(HardwareTimerBase const&) const;