Crate kernel_guard

source ·
Expand description

RAII wrappers to create a critical section with local IRQs or preemption disabled, used to implement spin locks in kernel.

The critical section is created after the guard struct is created, and is ended when the guard falls out of scope.

Available guards:

  • NoOp: Does nothing around the critical section.
  • IrqSave: Disables/enables local IRQs around the critical section.
  • NoPreempt: Disables/enables kernel preemption around the critical section.
  • NoPreemptIrqSave: Disables/enables both kernel preemption and local IRQs around the critical section.

Examples

let guard = NoPreempt::new();
/* The critical section starts here

Do something that requires preemption to be disabled

The critical section ends here */
drop(guard);

Structs

  • A guard that disables/enables local IRQs around the critical section.
  • A no-op guard that does nothing around the critical section.
  • A guard that disables/enables kernel preemption around the critical section.
  • A guard that disables/enables both kernel preemption and local IRQs around the critical section.

Traits

  • A base trait that all guards implement.