[sched] Fix the missing of preemption check in RISC-V & loongarch

This commit is contained in:
Yuke Peng 2025-10-20 10:55:58 +08:00 committed by Ruihan Li
parent 600446e9e1
commit 23f14df21f
3 changed files with 4 additions and 2 deletions

View File

@ -149,6 +149,7 @@ impl UserContextApiInternal for UserContext {
F: FnMut() -> bool,
{
let ret = loop {
crate::task::scheduler::might_preempt();
self.user_context.run();
let cause = loongArch64::register::estat::read().cause();

View File

@ -144,7 +144,9 @@ impl UserContextApiInternal for UserContext {
F: FnMut() -> bool,
{
let ret = loop {
crate::task::scheduler::might_preempt();
self.user_context.run();
match riscv::register::scause::read().cause() {
Trap::Interrupt(Interrupt::SupervisorTimer) => {
call_irq_callback_functions(

View File

@ -22,7 +22,6 @@ use crate::{
cpu::PrivilegeLevel,
irq::call_irq_callback_functions,
mm::Vaddr,
task::scheduler,
user::{ReturnReason, UserContextApi, UserContextApiInternal},
};
@ -271,7 +270,7 @@ impl UserContextApiInternal for UserContext {
// Return when it is syscall or cpu exception type is Fault or Trap.
loop {
scheduler::might_preempt();
crate::task::scheduler::might_preempt();
self.user_context.run();
let exception =