mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-19 12:36:46 +00:00
Remove the preempt guard from the IRQ guard
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
491e4325fa
commit
be54a39592
@ -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();
|
||||
|
@ -9,7 +9,6 @@ use trapframe::TrapFrame;
|
||||
use crate::{
|
||||
arch::irq::{self, IrqCallbackHandle, IRQ_ALLOCATOR},
|
||||
prelude::*,
|
||||
task::{disable_preempt, DisablePreemptGuard},
|
||||
Error,
|
||||
};
|
||||
|
||||
@ -135,7 +134,6 @@ pub fn disable_local() -> DisabledLocalIrqGuard {
|
||||
#[must_use]
|
||||
pub struct DisabledLocalIrqGuard {
|
||||
was_enabled: bool,
|
||||
preempt_guard: DisablePreemptGuard,
|
||||
}
|
||||
|
||||
impl !Send for DisabledLocalIrqGuard {}
|
||||
@ -146,11 +144,7 @@ impl DisabledLocalIrqGuard {
|
||||
if was_enabled {
|
||||
irq::disable_local();
|
||||
}
|
||||
let preempt_guard = disable_preempt();
|
||||
Self {
|
||||
was_enabled,
|
||||
preempt_guard,
|
||||
}
|
||||
Self { was_enabled }
|
||||
}
|
||||
|
||||
/// Transfers the saved IRQ status of this guard to a new guard.
|
||||
@ -158,10 +152,7 @@ impl DisabledLocalIrqGuard {
|
||||
pub fn transfer_to(&mut self) -> Self {
|
||||
let was_enabled = self.was_enabled;
|
||||
self.was_enabled = false;
|
||||
Self {
|
||||
was_enabled,
|
||||
preempt_guard: disable_preempt(),
|
||||
}
|
||||
Self { was_enabled }
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user