mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:28:11 +00:00
Kernel: Abstract platform-specific current time methods from Scheduler
This change ensures that the scheduler doesn't depend on a platform specific or arch-specific code when it initializes itself, but rather we ensure that in compile-time we will generate the appropriate code to find the correct arch-specific current time methods.
This commit is contained in:
parent
c439a34ff7
commit
3651d9701e
5 changed files with 71 additions and 11 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <AK/Time.h>
|
||||
#include <Kernel/Arch/CurrentTime.h>
|
||||
#include <Kernel/Arch/InterruptDisabler.h>
|
||||
#include <Kernel/Arch/x86/TrapFrame.h>
|
||||
#include <Kernel/Debug.h>
|
||||
|
@ -365,11 +366,6 @@ Process* Scheduler::colonel()
|
|||
return s_colonel_process;
|
||||
}
|
||||
|
||||
static u64 current_time_tsc()
|
||||
{
|
||||
return read_tsc();
|
||||
}
|
||||
|
||||
static u64 current_time_monotonic()
|
||||
{
|
||||
// We always need a precise timestamp here, we cannot rely on a coarse timestamp
|
||||
|
@ -380,13 +376,11 @@ UNMAP_AFTER_INIT void Scheduler::initialize()
|
|||
{
|
||||
VERIFY(Processor::is_initialized()); // sanity check
|
||||
|
||||
// Figure out a good scheduling time source
|
||||
if (Processor::current().has_feature(CPUFeature::TSC) && Processor::current().has_feature(CPUFeature::CONSTANT_TSC)) {
|
||||
current_time = current_time_tsc;
|
||||
} else {
|
||||
// TODO: Using HPET is rather slow, can we use any other time source that may be faster?
|
||||
auto* possible_arch_specific_current_time_function = optional_current_time();
|
||||
if (possible_arch_specific_current_time_function)
|
||||
current_time = possible_arch_specific_current_time_function;
|
||||
else
|
||||
current_time = current_time_monotonic;
|
||||
}
|
||||
|
||||
LockRefPtr<Thread> idle_thread;
|
||||
g_finalizer_wait_queue = new WaitQueue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue