mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
[kernel] Keep other threads out of idle priority
Split out different constants for scheduler::idle_priority and scheduler::max_priority, so that threads never fall to the same priority level as the idle threads.
This commit is contained in:
@@ -12,7 +12,6 @@
|
||||
#include "logger.h"
|
||||
#include "msr.h"
|
||||
#include "objects/thread.h"
|
||||
#include "scheduler.h"
|
||||
#include "syscall.h"
|
||||
#include "tss.h"
|
||||
|
||||
@@ -162,7 +161,6 @@ cpu_init(cpu_data *cpu, bool bsp)
|
||||
|
||||
obj::thread *idle = obj::thread::create_idle_thread(
|
||||
g_kernel_process,
|
||||
scheduler::max_priority,
|
||||
cpu->rsp0);
|
||||
|
||||
cpu->thread = idle;
|
||||
|
||||
@@ -171,9 +171,9 @@ thread::setup_kernel_stack()
|
||||
}
|
||||
|
||||
thread *
|
||||
thread::create_idle_thread(process &kernel, uint8_t pri, uintptr_t rsp0)
|
||||
thread::create_idle_thread(process &kernel, uintptr_t rsp0)
|
||||
{
|
||||
thread *idle = new thread(kernel, pri, rsp0);
|
||||
thread *idle = new thread(kernel, scheduler::idle_priority, rsp0);
|
||||
idle->set_state(state::constant);
|
||||
idle->set_state(state::ready);
|
||||
return idle;
|
||||
|
||||
@@ -168,9 +168,8 @@ public:
|
||||
|
||||
/// Create the kernel idle thread
|
||||
/// \arg kernel The process object that owns kernel tasks
|
||||
/// \arg pri The idle thread priority value
|
||||
/// \arg rsp The existing stack for the idle thread
|
||||
static thread * create_idle_thread(process &kernel, uint8_t pri, uintptr_t rsp);
|
||||
static thread * create_idle_thread(process &kernel, uintptr_t rsp);
|
||||
|
||||
protected:
|
||||
/// Don't delete a thread on no handles, the scheduler takes
|
||||
|
||||
@@ -226,8 +226,8 @@ scheduler::steal_work(cpu_data &cpu)
|
||||
|
||||
size_t stolen = 0;
|
||||
|
||||
// Don't steal from max_priority, that's the idle thread
|
||||
for (unsigned pri = 0; pri < max_priority; ++pri)
|
||||
// Steal from most urgent queues first, don't steal idle threads
|
||||
for (unsigned pri = 0; pri < idle_priority; ++pri)
|
||||
stolen += balance_lists(my_queue.ready[pri], other_queue.ready[pri], cpu);
|
||||
|
||||
stolen += balance_lists(my_queue.blocked, other_queue.blocked, cpu);
|
||||
@@ -334,6 +334,7 @@ void
|
||||
scheduler::maybe_schedule(TCB *t)
|
||||
{
|
||||
cpu_data *cpu = t->cpu;
|
||||
kassert(cpu, "thread with a null cpu");
|
||||
|
||||
run_queue &queue = m_run_queues[cpu->index];
|
||||
uint8_t current_pri = queue.current->priority;
|
||||
|
||||
@@ -29,8 +29,11 @@ public:
|
||||
/// Total number of priority levels
|
||||
static const uint8_t num_priorities = 8;
|
||||
|
||||
/// Idle task priority, less urgent than anything
|
||||
static const uint8_t idle_priority = num_priorities - 1;
|
||||
|
||||
/// Maximum (least urgent/interactive) priority
|
||||
static const uint8_t max_priority = num_priorities - 1;
|
||||
static const uint8_t max_priority = idle_priority - 1;
|
||||
|
||||
/// Default priority on process creation
|
||||
static const uint8_t default_priority = 1;
|
||||
|
||||
Reference in New Issue
Block a user