Function ostd::trap::disable_local
source · pub fn disable_local() -> DisabledLocalIrqGuard
Expand description
Disables all IRQs on the current CPU (i.e., locally).
This function returns a guard object, which will automatically enable local IRQs again when it is dropped. This function works correctly even when it is called in a nested way. The local IRQs shall only be re-enabled when the most outer guard is dropped.
This function can play nicely with SpinLock
as the type uses this function internally.
One can invoke this function even after acquiring a spin lock. And the reversed order is also ok.
§Example
use ostd::irq;
{
let _ = irq::disable_local();
todo!("do something when irqs are disabled");
}