mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-28 20:03:22 +00:00
Don't race between enabling IRQs and halting CPU
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
b96c8f9ed2
commit
35e0918bce
@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user