mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-19 20:46:35 +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
|
/// If the current task's status not [`TaskStatus::Runnable`], it will not be
|
||||||
/// added to the scheduler.
|
/// 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>) {
|
fn switch_to_task(next_task: Arc<Task>) {
|
||||||
let preemt_lock_count = PREEMPT_LOCK_COUNT.load();
|
let preemt_lock_count = PREEMPT_LOCK_COUNT.load();
|
||||||
if preemt_lock_count != 0 {
|
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 irq_guard = crate::trap::disable_local();
|
||||||
|
|
||||||
let current_task_ptr = CURRENT_TASK_PTR.load();
|
let current_task_ptr = CURRENT_TASK_PTR.load();
|
||||||
|
@ -9,7 +9,6 @@ use trapframe::TrapFrame;
|
|||||||
use crate::{
|
use crate::{
|
||||||
arch::irq::{self, IrqCallbackHandle, IRQ_ALLOCATOR},
|
arch::irq::{self, IrqCallbackHandle, IRQ_ALLOCATOR},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
task::{disable_preempt, DisablePreemptGuard},
|
|
||||||
Error,
|
Error,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -135,7 +134,6 @@ pub fn disable_local() -> DisabledLocalIrqGuard {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
pub struct DisabledLocalIrqGuard {
|
pub struct DisabledLocalIrqGuard {
|
||||||
was_enabled: bool,
|
was_enabled: bool,
|
||||||
preempt_guard: DisablePreemptGuard,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl !Send for DisabledLocalIrqGuard {}
|
impl !Send for DisabledLocalIrqGuard {}
|
||||||
@ -146,11 +144,7 @@ impl DisabledLocalIrqGuard {
|
|||||||
if was_enabled {
|
if was_enabled {
|
||||||
irq::disable_local();
|
irq::disable_local();
|
||||||
}
|
}
|
||||||
let preempt_guard = disable_preempt();
|
Self { was_enabled }
|
||||||
Self {
|
|
||||||
was_enabled,
|
|
||||||
preempt_guard,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transfers the saved IRQ status of this guard to a new guard.
|
/// 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 {
|
pub fn transfer_to(&mut self) -> Self {
|
||||||
let was_enabled = self.was_enabled;
|
let was_enabled = self.was_enabled;
|
||||||
self.was_enabled = false;
|
self.was_enabled = false;
|
||||||
Self {
|
Self { was_enabled }
|
||||||
was_enabled,
|
|
||||||
preempt_guard: disable_preempt(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user