Expand description
Synchronisation primitives.
This module contains the kernel APIs related to synchronisation that have been ported or wrapped for usage by Rust code in the kernel.
Examples
// SAFETY: `init` is called below.
let mut data = Pin::from(Box::try_new(unsafe { Mutex::new(10) }).unwrap());
mutex_init!(data.as_mut(), "test::data");
assert_eq!(*data.lock(), 10);
*data.lock() = 20;
assert_eq!(*data.lock(), 20);
Modules
Structs
A reference-counted pointer to an instance of
T
.Exposes the kernel’s
struct wait_queue_head
as a condition variable. It allows the caller to
atomically release the given lock and go to sleep. It reacquires the lock when it wakes up. And
it wakes up when notified by another thread (via CondVar::notify_one
or
CondVar::notify_all
) or because the thread received a signal.Allows mutual exclusion primitives that implement the
Lock
trait to automatically unlock
when a guard goes out of scope. It also provides a safe and convenient way to access the data
protected by the lock.Represents a lockdep class. It’s a wrapper around C’s
lock_class_key
.Allows access to some data to be serialised by a lock that does not wrap it.
Exposes the kernel’s
struct mutex
. When multiple threads attempt to lock the same mutex,
only one at a time is allowed to progress, the others will block (sleep) until the mutex is
unlocked, at which point another thread will be allowed to wake up and make progress.A lock that only offers a
try_lock
method.A guard for the holder of the no-wait lock.
Exposes the kernel’s
raw_spinlock_t
.A marker for locks that only allow reading.
Revocable synchronisation primitive.
A guard that allows access to a revocable object and keeps it alive.
Exposes the kernel’s
struct rw_semaphore
.Exposes sequential locks backed by the kernel’s
seqcount_t
.Allows read-side access to data protected by a sequential lock.
Exposes the kernel’s
spinlock_t
. When multiple CPUs attempt to lock the same spinlock, only
one at a time is allowed to progress, the others will block (spinning) until the spinlock is
unlocked, at which point another CPU will be allowed to make progress.Allows the creation of “reference-counted” globals.
A refcounted object that is known to have a refcount of 1.
A marker for locks that allow reading and writing.
Traits
A generic mutual exclusion primitive.
A creator of instances of a mutual exclusion (lock) primitive.
Specifies properties of a lock.
A lock that can be initialised with a single lock class key.
A trait for types that need a lock class during initialisation.
Functions
Reschedules the caller’s task if needed.
Creates, from a const context, a new instance of
struct refcount_struct
with a refcount of 1.Type Definitions
A revocable mutex.
A guard for a revocable mutex.
A revocable rw semaphore.
A guard for a revocable rw semaphore..