Remove the preempt guard from the IRQ guard

This commit is contained in:
Zhang Junyang
2024-08-12 13:04:53 +00:00
committed by Tate, Hongliang Tian
parent 491e4325fa
commit be54a39592
2 changed files with 12 additions and 11 deletions

View File

@ -71,6 +71,11 @@ pub fn preempt(task: &Arc<Task>) {
///
/// If the current task's status not [`TaskStatus::Runnable`], it will not be
/// added to the scheduler.
///
/// # Panics
///
/// This function will panic if called while holding preemption locks or with
/// local IRQ disabled.
fn switch_to_task(next_task: Arc<Task>) {
let preemt_lock_count = PREEMPT_LOCK_COUNT.load();
if preemt_lock_count != 0 {
@ -80,6 +85,11 @@ fn switch_to_task(next_task: Arc<Task>) {
);
}
assert!(
crate::arch::irq::is_local_enabled(),
"Switching task with local IRQ disabled"
);
let irq_guard = crate::trap::disable_local();
let current_task_ptr = CURRENT_TASK_PTR.load();