kernel_guard

Crates.io

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.

The crate user must implement the KernelGuardIf trait using crate_interface::impl_interface to provide the low-level implementantion of how to enable/disable kernel preemption, if the feature preempt is enabled.

Available guards:

Crate features

Examples

```rust use kernel_guard::{KernelGuardIf, NoPreempt};

struct KernelGuardIfImpl;

[crateinterface::implinterface]

impl KernelGuardIf for KernelGuardIfImpl { fn enablepreempt() { // Your implementation here } fn disablepreempt() { // Your implementation here } }

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

Do something that requires preemption to be disabled

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