mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
Give processes multiple quanta before rescheduling
This commit is contained in:
@@ -35,7 +35,7 @@ struct process
|
|||||||
|
|
||||||
process_flags flags;
|
process_flags flags;
|
||||||
|
|
||||||
uint16_t reserved0;
|
uint16_t quanta;
|
||||||
|
|
||||||
uint8_t priority;
|
uint8_t priority;
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,6 @@
|
|||||||
#include "kutil/assert.h"
|
#include "kutil/assert.h"
|
||||||
|
|
||||||
scheduler scheduler::s_instance(nullptr);
|
scheduler scheduler::s_instance(nullptr);
|
||||||
static const uint64_t quantum_micros = 1000000;
|
|
||||||
//static const uint32_t quantum_micros = 20000000;
|
|
||||||
|
|
||||||
const int stack_size = 0x1000;
|
const int stack_size = 0x1000;
|
||||||
const uint64_t rflags_noint = 0x002;
|
const uint64_t rflags_noint = 0x002;
|
||||||
@@ -39,6 +37,7 @@ scheduler::scheduler(lapic *apic) :
|
|||||||
idle->priority = last_pri;
|
idle->priority = last_pri;
|
||||||
idle->rsp = 0; // This will get set when we switch away
|
idle->rsp = 0; // This will get set when we switch away
|
||||||
idle->pml4 = page_manager::get_pml4();
|
idle->pml4 = page_manager::get_pml4();
|
||||||
|
idle->quanta = process_quanta;
|
||||||
idle->flags =
|
idle->flags =
|
||||||
process_flags::running |
|
process_flags::running |
|
||||||
process_flags::ready |
|
process_flags::ready |
|
||||||
@@ -156,6 +155,7 @@ scheduler::create_process(const char *name, const void *data, size_t size)
|
|||||||
proc->priority = default_priority;
|
proc->priority = default_priority;
|
||||||
proc->rsp = reinterpret_cast<addr_t>(loader_state);
|
proc->rsp = reinterpret_cast<addr_t>(loader_state);
|
||||||
proc->pml4 = pml4;
|
proc->pml4 = pml4;
|
||||||
|
proc->quanta = process_quanta;
|
||||||
proc->flags =
|
proc->flags =
|
||||||
process_flags::running |
|
process_flags::running |
|
||||||
process_flags::ready |
|
process_flags::ready |
|
||||||
@@ -271,9 +271,10 @@ scheduler::schedule(addr_t rsp0)
|
|||||||
addr_t
|
addr_t
|
||||||
scheduler::tick(addr_t rsp0)
|
scheduler::tick(addr_t rsp0)
|
||||||
{
|
{
|
||||||
// TODO: action based on the task using the whole quantum
|
if (--m_current->quanta == 0) {
|
||||||
|
m_current->quanta = process_quanta;
|
||||||
rsp0 = schedule(rsp0);
|
rsp0 = schedule(rsp0);
|
||||||
|
}
|
||||||
m_apic->reset_timer(m_tick_count);
|
m_apic->reset_timer(m_tick_count);
|
||||||
return rsp0;
|
return rsp0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ public:
|
|||||||
static const uint8_t num_priorities = 8;
|
static const uint8_t num_priorities = 8;
|
||||||
static const uint8_t default_priority = num_priorities / 2;
|
static const uint8_t default_priority = num_priorities / 2;
|
||||||
|
|
||||||
|
/// How long the timer quantum is
|
||||||
|
static const uint64_t quantum_micros = 100000;
|
||||||
|
|
||||||
|
/// How many quantums a process gets before being rescheduled
|
||||||
|
static const uint16_t process_quanta = 10;
|
||||||
|
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// \arg apic Pointer to the local APIC object
|
/// \arg apic Pointer to the local APIC object
|
||||||
scheduler(lapic *apic);
|
scheduler(lapic *apic);
|
||||||
|
|||||||
Reference in New Issue
Block a user