diff --git a/arch/x86/mm/svm.c b/arch/x86/mm/svm.c index f0b772d4..588618bd 100644 --- a/arch/x86/mm/svm.c +++ b/arch/x86/mm/svm.c @@ -132,7 +132,7 @@ int svm_access_request(size_t addr) icc_mail_check(0); while (page_owner[pageid] != my_ue) { - check_workqueues_rem_irq(); + check_workqueues(); } return change_page_permissions(addr, addr+PAGE_SIZE, VMA_READ|VMA_WRITE|VMA_CACHEABLE); diff --git a/include/metalsvm/tasks.h b/include/metalsvm/tasks.h index 7f3c7221..8dd950f8 100644 --- a/include/metalsvm/tasks.h +++ b/include/metalsvm/tasks.h @@ -176,12 +176,9 @@ 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 +/** @brief if a task exists with higher priority, MetalSVM switch to it. */ -uint32_t get_highest_priority(uint32_t core_id); +void check_scheduling(void); /** @brief Call to rescheduling * @@ -194,6 +191,7 @@ static inline void check_workqueues(void) #ifdef CONFIG_ROCKCREEK icc_mail_check(0); #endif + check_scheduling(); } static inline void check_workqueues_rem_irq(void) diff --git a/kernel/main.c b/kernel/main.c index 6a18cdc8..c458c3aa 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -94,12 +94,9 @@ int main(void) create_kernel_task(NULL, initd, NULL, NORMAL_PRIO); reschedule(); - while(1) { -#ifdef CONFIG_ROCKCREEK - //icc_halt(); -#else + while(1) { + check_workqueues(); HALT; -#endif } return 0; diff --git a/kernel/syscall.c b/kernel/syscall.c index 8f52a2d2..6eaecd28 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -91,7 +91,7 @@ int syscall_handler(uint32_t sys_nr, ...) int ret = -EINVAL; va_list vl; - check_workqueues_rem_irq(); + check_workqueues(); va_start(vl, sys_nr); diff --git a/kernel/tasks.c b/kernel/tasks.c index 0689d401..910a0605 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -68,8 +68,11 @@ task_t* get_current_task(void) { return per_core(current_task); } -uint32_t get_highest_priority(uint32_t core_id) { - return msb(runqueues[core_id].prio_bitmap); +void check_scheduling(void) { + if (!is_irq_enabled()) + return; + if (msb(runqueues[CORE_ID].prio_bitmap) > per_core(current_task)->prio) + reschedule(); } int multitasking_init(void) {