Halt the idle CPUs

This commit is contained in:
Zhang Junyang
2025-03-05 11:31:56 +08:00
committed by Tate, Hongliang Tian
parent 265bc25dd7
commit 30ec0be210
6 changed files with 48 additions and 12 deletions

View File

@ -4,3 +4,17 @@
pub mod context;
pub mod local;
/// 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();
}