From 9a3f10d68602feb9c5b2c4ebe3d24963c4a0b918 Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Tue, 20 Mar 2018 11:25:00 +0100 Subject: [PATCH] Start with the task with higher priority! --- kernel/src/scheduler.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/src/scheduler.cpp b/kernel/src/scheduler.cpp index 310372a8..fc23d815 100644 --- a/kernel/src/scheduler.cpp +++ b/kernel/src/scheduler.cpp @@ -70,6 +70,7 @@ volatile size_t next_pid = 0; size_t gc_pid = 0; size_t idle_pid = 0; size_t init_pid = 0; +size_t post_init_pid = 0; std::vector& run_queue(size_t priority){ return run_queues[priority - scheduler::MIN_PRIORITY]; @@ -353,9 +354,11 @@ void create_post_init_task(){ post_init_process.ppid = 1; post_init_process.priority = scheduler::MAX_PRIORITY; - scheduler::queue_system_process(post_init_process.pid); + post_init_pid = post_init_process.pid; - logging::logf(logging::log_level::DEBUG, "scheduler: post_init_task %u \n", post_init_process.pid); + scheduler::queue_system_process(post_init_pid); + + logging::logf(logging::log_level::DEBUG, "scheduler: post_init_task %u \n", post_init_pid); } void switch_to_process(size_t pid){ @@ -669,8 +672,8 @@ void scheduler::init(){ } void scheduler::start(){ - //Run the init task by default - current_pid = init_pid; + //Run the post init task by default (maximum priority) + current_pid = post_init_pid; pcb[current_pid].state = scheduler::process_state::RUNNING; started = true;