From 426c1e33fd2ac9d85885a8a0b121d5799946fa3c Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Sat, 9 Jul 2016 16:30:25 +0200 Subject: [PATCH] Improve interface --- kernel/include/scheduler.hpp | 1 + kernel/src/scheduler.cpp | 31 +++++++++++++++---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/kernel/include/scheduler.hpp b/kernel/include/scheduler.hpp index e0e48eed..6c5c6b7d 100644 --- a/kernel/include/scheduler.hpp +++ b/kernel/include/scheduler.hpp @@ -50,6 +50,7 @@ void block_process_light(pid_t pid); //TODO Maybe do that for unblock as well! process_t& create_kernel_task(char* user_stack, char* kernel_stack, void (*fun)()); +void queue_system_process(pid_t pid); } //end of namespace scheduler diff --git a/kernel/src/scheduler.cpp b/kernel/src/scheduler.cpp index 70768d92..baccf055 100644 --- a/kernel/src/scheduler.cpp +++ b/kernel/src/scheduler.cpp @@ -189,19 +189,6 @@ scheduler::process_t& new_process(){ return process.process; } -void queue_system_process(scheduler::pid_t pid){ - thor_assert(pid < scheduler::MAX_PROCESS, "pid out of bounds"); - - auto& process = pcb[pid]; - - thor_assert(process.process.priority <= scheduler::MAX_PRIORITY, "Invalid priority"); - thor_assert(process.process.priority >= scheduler::MIN_PRIORITY, "Invalid priority"); - - process.state = scheduler::process_state::READY; - - run_queue(process.process.priority).push_back(pid); -} - void queue_process(scheduler::pid_t pid){ thor_assert(pid < scheduler::MAX_PROCESS, "pid out of bounds"); @@ -222,7 +209,7 @@ void create_idle_task(){ idle_process.ppid = 0; idle_process.priority = scheduler::MIN_PRIORITY; - queue_system_process(idle_process.pid); + scheduler::queue_system_process(idle_process.pid); idle_pid = idle_process.pid; } @@ -233,7 +220,7 @@ void create_init_task(){ init_process.ppid = 0; init_process.priority = scheduler::MIN_PRIORITY + 1; - queue_system_process(init_process.pid); + scheduler::queue_system_process(init_process.pid); } void create_gc_task(){ @@ -242,7 +229,7 @@ void create_gc_task(){ gc_process.ppid = 1; gc_process.priority = scheduler::MIN_PRIORITY + 1; - queue_system_process(gc_process.pid); + scheduler::queue_system_process(gc_process.pid); gc_pid = gc_process.pid; } @@ -881,3 +868,15 @@ scheduler::process_t& scheduler::create_kernel_task(char* user_stack, char* kern return process; } +void scheduler::queue_system_process(scheduler::pid_t pid){ + thor_assert(pid < scheduler::MAX_PROCESS, "pid out of bounds"); + + auto& process = pcb[pid]; + + thor_assert(process.process.priority <= scheduler::MAX_PRIORITY, "Invalid priority"); + thor_assert(process.process.priority >= scheduler::MIN_PRIORITY, "Invalid priority"); + + process.state = scheduler::process_state::READY; + + run_queue(process.process.priority).push_back(pid); +}