mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[kernel] Don't double-construct the scheduler
The scheduler singleton was getting constructed twice, once at static time and then again in main(). Make the singleton a pointer so we only construct it once.
This commit is contained in:
@@ -174,7 +174,7 @@ kernel_main(args::header *header)
|
||||
devices.init_drivers();
|
||||
|
||||
syscall_enable();
|
||||
scheduler *sched = new (&scheduler::get()) scheduler(devices.get_lapic());
|
||||
scheduler *sched = new scheduler(devices.get_lapic());
|
||||
|
||||
sched->create_kernel_task(logger_task, scheduler::max_priority-1, true);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "elf/elf.h"
|
||||
#include "kutil/assert.h"
|
||||
|
||||
scheduler scheduler::s_instance(nullptr);
|
||||
scheduler *scheduler::s_instance = nullptr;
|
||||
|
||||
const uint64_t rflags_noint = 0x002;
|
||||
const uint64_t rflags_int = 0x202;
|
||||
@@ -34,6 +34,9 @@ scheduler::scheduler(lapic *apic) :
|
||||
m_clock(0),
|
||||
m_last_promotion(0)
|
||||
{
|
||||
kassert(!s_instance, "Multiple schedulers created!");
|
||||
s_instance = this;
|
||||
|
||||
page_table *pml4 = page_manager::get_pml4();
|
||||
process *kp = new process(pml4);
|
||||
m_kernel_process = kp;
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
|
||||
/// Get a reference to the system scheduler
|
||||
/// \returns A reference to the global system scheduler
|
||||
static scheduler & get() { return s_instance; }
|
||||
static scheduler & get() { return *s_instance; }
|
||||
|
||||
private:
|
||||
friend uintptr_t syscall_dispatch(uintptr_t, cpu_state &);
|
||||
@@ -105,6 +105,6 @@ private:
|
||||
uint64_t m_clock = 0;
|
||||
uint64_t m_last_promotion;
|
||||
|
||||
static scheduler s_instance;
|
||||
static scheduler *s_instance;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user