xtc_rcu(3)
---xtc_rcu(3)
epoch-based read-copy-update
| XTC_RCU(3) | Library Functions Manual | XTC_RCU(3) |
NAME
xtc_rcu_init,
xtc_rcu_fini,
xtc_rcu_read_lock,
xtc_rcu_read_unlock,
xtc_rcu_retire,
xtc_rcu_synchronize,
xtc_rcu_current_epoch —
epoch-based read-copy-update
SYNOPSIS
#include <xtc.h>
#include <xtc_rcu.h>
int
xtc_rcu_init(void);
void
xtc_rcu_fini(void);
void
xtc_rcu_read_lock(void);
void
xtc_rcu_read_unlock(void);
void
xtc_rcu_retire(void
*p, xtc_rcu_free_fn
fn);
void
xtc_rcu_synchronize(void);
uint64_t
xtc_rcu_current_epoch(void);
DESCRIPTION
xtc_rcu is an epoch-based read-copy-update
primitive for read-mostly data structures with deferred reclamation. Readers
operate
wait-free
inside critical sections delimited by
xtc_rcu_read_lock()
and
xtc_rcu_read_unlock().
Writers atomically swap pointers to new state and call
xtc_rcu_retire()
to free the old state once all readers that may have observed it have exited
their critical sections.
xtc_rcu_synchronize()
blocks until all currently-active readers have exited. Used by writers that
want to free old state synchronously rather than via the deferred-retire
path.
The implementation tracks per-thread epoch counters in a TLS-registered linked list. Retired records bucket by epoch; records two epochs old are guaranteed safe to free.
xtc_rcu_current_epoch()
returns the current value of the global epoch counter. It is intended for
diagnostics and tests -- the counter advances on each grace period.
CHOOSING vs. xtc_lrlock
Both give wait-free reads. Trade-offs:
- xtc_rcu
- Pointer-swap; arbitrary structure shape; deferred reclamation. Best when the structure is small or rare-write.
- xtc_lrlock
- Two-copy + replay; suits structures where the data is updated in place (buffer pools, page caches). Memory is 2x; reclamation is immediate via the publish-drain.
SEE ALSO
HISTORY
Appeared in xtc 0.1.
| May 28, 2026 | Debian |