From b2012b36692100db7d296b9383914b1f0382f004 Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Tue, 4 Feb 2014 20:14:10 +0100 Subject: [PATCH] Fix warnings --- kernel/include/assert.hpp | 1 + kernel/include/process.hpp | 6 +++--- kernel/src/scheduler.cpp | 12 ++++++++---- kernel/src/shell.cpp | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/kernel/include/assert.hpp b/kernel/include/assert.hpp index 32801563..d668a515 100644 --- a/kernel/include/assert.hpp +++ b/kernel/include/assert.hpp @@ -25,6 +25,7 @@ inline void thor_assert(bool condition, const char* message){ } #endif +inline void thor_unreachable(const char* message) __attribute__((noreturn)); inline void thor_unreachable(const char* message){ __thor_unreachable(message); __builtin_unreachable(); diff --git a/kernel/include/process.hpp b/kernel/include/process.hpp index 8071dabb..9119884a 100644 --- a/kernel/include/process.hpp +++ b/kernel/include/process.hpp @@ -16,10 +16,10 @@ namespace scheduler { -constexpr const size_t MAX_PRIORITY = 3; -constexpr const size_t MIN_PRIORITY = 0; +constexpr const size_t MAX_PRIORITY = 4; +constexpr const size_t MIN_PRIORITY = 1; constexpr const size_t PRIORITY_LEVELS = MAX_PRIORITY - MIN_PRIORITY + 1; -constexpr const size_t DEFAULT_PRIORITY = 2; +constexpr const size_t DEFAULT_PRIORITY = 3; typedef size_t pid_t; diff --git a/kernel/src/scheduler.cpp b/kernel/src/scheduler.cpp index 4c9eb12e..eed2e85a 100644 --- a/kernel/src/scheduler.cpp +++ b/kernel/src/scheduler.cpp @@ -44,6 +44,10 @@ std::array pcb; //Define one run queue for each priority level std::array, scheduler::PRIORITY_LEVELS> run_queues; +std::vector& run_queue(size_t priority){ + return run_queues[priority - scheduler::MIN_PRIORITY]; +} + bool started = false; constexpr const size_t TURNOVER = 10; @@ -104,7 +108,7 @@ void queue_process(scheduler::pid_t pid){ process.state = scheduler::process_state::READY; - run_queues[process.process.priority].push_back(pid); + run_queue(process.process.priority).push_back(pid); } scheduler::process_t& create_kernel_task(char* user_stack, char* kernel_stack, void (*fun)()){ @@ -174,7 +178,7 @@ size_t select_next_process(){ //1. Run a process of higher priority, if any for(size_t p = scheduler::MAX_PRIORITY; p > current_priority; --p){ - for(auto pid : run_queues[p]){ + for(auto pid : run_queue(p)){ if(pcb[pid].state == scheduler::process_state::READY){ return pid; } @@ -183,7 +187,7 @@ size_t select_next_process(){ //2. Run the next process of the same priority - auto& current_run_queue = run_queues[current_priority]; + auto& current_run_queue = run_queue(current_priority); size_t next_index = 0; for(size_t i = 0; i < current_run_queue.size(); ++i){ @@ -207,7 +211,7 @@ size_t select_next_process(){ //3. Run a process of lower priority for(size_t p = current_priority - 1; p >= scheduler::MIN_PRIORITY; --p){ - for(auto pid : run_queues[p]){ + for(auto pid : run_queue(p)){ if(pcb[pid].state == scheduler::process_state::READY){ return pid; } diff --git a/kernel/src/shell.cpp b/kernel/src/shell.cpp index c61b4358..7682dd59 100644 --- a/kernel/src/shell.cpp +++ b/kernel/src/shell.cpp @@ -720,7 +720,7 @@ void readelf_command(const std::vector& params){ } } -void exec_command(const std::vector& params){ +void exec_command(const std::vector&){ //Fake exec just to start() the scheduler scheduler::exec(""); }