diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index 2be72709..7361e3cc 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c @@ -275,13 +275,10 @@ void irq_handler(struct state *s) #endif leave_handler: -#ifdef CONFIG_ROCKCREEK - // add fast lane for the driver task - if (s->int_no >= 32) - scheduler(); -#else // timer interrupt? if ((s->int_no == 32) || (s->int_no == 123)) scheduler(); // switch to a new task -#endif + // exists a new (driver) task with a higher priority? + else if ((s->int_no >= 32) && (get_highest_priority(CORE_ID) > per_core(current_task)->prio)) + scheduler(); } diff --git a/include/metalsvm/tasks.h b/include/metalsvm/tasks.h index be3fdd07..9ef7295f 100644 --- a/include/metalsvm/tasks.h +++ b/include/metalsvm/tasks.h @@ -176,6 +176,13 @@ size_t get_idle_task(uint32_t id); */ int sys_execve(const char* fname, char** argv, char** env); +/** @brief determines the highest priority of all ready tasks on core core_id + * + * @param core_id core id + * @return highest priority + */ +uint32_t get_highest_priority(uint32_t core_id); + /** @brief Call to rescheduling * * This is a purely assembled procedure for rescheduling diff --git a/kernel/tasks.c b/kernel/tasks.c index 0613fc95..7bf87879 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -68,6 +68,10 @@ task_t* get_current_task(void) { return per_core(current_task); } +uint32_t get_highest_priority(uint32_t core_id) { + return last_set(runqueues[core_id].prio_bitmap); +} + int multitasking_init(void) { if (BUILTIN_EXPECT(task_table[0].status != TASK_IDLE, 0)) { kputs("Task 0 is not an idle task\n");