Don't race between enabling IRQs and halting CPU

This commit is contained in:
Ruihan Li
2025-04-09 10:23:58 +08:00
committed by Tate, Hongliang Tian
parent b96c8f9ed2
commit 35e0918bce
11 changed files with 105 additions and 42 deletions

View File

@ -7,17 +7,3 @@ pub mod extension;
pub mod local;
pub use extension::{has_extensions, IsaExtensions};
/// Halts the CPU.
///
/// This function halts the CPU until the next interrupt is received. By
/// halting, the CPU might consume less power. Internally it is implemented
/// using the `wfi` instruction.
///
/// Since the function sleeps the CPU, it should not be used within an atomic
/// mode ([`crate::task::atomic_mode`]).
#[track_caller]
pub fn sleep_for_interrupt() {
crate::task::atomic_mode::might_sleep();
riscv::asm::wfi();
}