⚠️ VeridianOS Kernel Documentation - This is low-level kernel code. All functions are unsafe unless explicitly marked otherwise. no_std

Module rcu

Module rcu 

Source
Expand description

Read-Copy-Update (RCU) Synchronization

RCU provides extremely fast read-side access to shared data structures without locks. Readers proceed without synchronization overhead while writers create copies, update pointers atomically, and reclaim old versions after a grace period.

This implementation uses a simplified epoch-based reclamation scheme suitable for a microkernel with a small number of CPUs:

  • Readers call rcu_read_lock() / rcu_read_unlock() to mark critical sections (these compile to atomic counter increments, no actual locks).
  • Writers call synchronize_rcu() to wait for all pre-existing readers to complete, or call_rcu() to defer cleanup to a callback.
  • Grace period detection uses per-CPU counters: when all CPUs have passed through a quiescent state (context switch or explicit rcu_quiescent()), the grace period is complete.

Functions§

call_rcu
Register a deferred callback to be called after the next grace period.
rcu_is_reading
Check whether the current CPU is inside an RCU read-side critical section.
rcu_quiescent
Report that the current CPU has passed through a quiescent state.
rcu_read_lock
Enter an RCU read-side critical section.
rcu_read_unlock
Exit an RCU read-side critical section.
synchronize_rcu
Wait for all pre-existing RCU read-side critical sections to complete.