mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-16 08:46:48 +00:00
Keep interrupts disabled during context switching
This commit is contained in:
parent
9b38eff5fe
commit
3d63ed7a4c
@ -163,6 +163,9 @@ impl TaskOptions {
|
||||
/// all task will entering this function
|
||||
/// this function is mean to executing the task_fn in Task
|
||||
extern "C" fn kernel_task_entry() -> ! {
|
||||
// See `switch_to_task` for why we need this.
|
||||
crate::arch::irq::enable_local();
|
||||
|
||||
let current_task = Task::current()
|
||||
.expect("no current task, it should have current task in kernel task entry");
|
||||
|
||||
|
@ -69,7 +69,9 @@ pub(super) fn switch_to_task(next_task: Arc<Task>) {
|
||||
drop(unsafe { Arc::from_raw(old_prev) });
|
||||
}
|
||||
|
||||
drop(irq_guard);
|
||||
// Keep interrupts disabled during context switching. This will be enabled after switching to
|
||||
// the target task (in the code below or in `kernel_task_entry`).
|
||||
core::mem::forget(irq_guard);
|
||||
|
||||
// SAFETY:
|
||||
// 1. `ctx` is only used in `reschedule()`. We have exclusive access to both the current task
|
||||
@ -85,4 +87,7 @@ pub(super) fn switch_to_task(next_task: Arc<Task>) {
|
||||
// always possible. For example, `context_switch` can switch directly to the entry point of the
|
||||
// next task. Not dropping is just fine because the only consequence is that we delay the drop
|
||||
// to the next task switching.
|
||||
|
||||
// See also `kernel_task_entry`.
|
||||
crate::arch::irq::enable_local();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user