Crate hermit_sync
source ·Expand description
Overview
hermit-sync provides synchronization primitives targeted at operating system kernels.
Interrupts
without_interrupts runs a closure with disabled interrupts.
Mutexes
This crate provides three kinds of mutexes based on lock_api::RawMutex:
RawSpinMutexis a simple test and test-and-set spinlock with exponential backoff.RawTicketMutexis a fair ticket lock with exponential backoff.RawInterruptMutexwraps another mutex and disables interrupts while locked.
For API documentation see lock_api::Mutex.
Initializing Static Data
There are two primitives for safely initializing static data based on generic_once_cell and RawSpinMutex:
OnceCellcan be written to only once and can then be accessed without locking.Lazywraps aOnceCelland is initialized on the first access from a closure.
For API documentation see generic_once_cell::OnceCell and generic_once_cell::Lazy.
Type Definitions
This crate provides a lot of type definitions for ease of use:
Structs
An interrupt-safe mutex.
Functions
Run a closure with disabled interrupts.