| MEMBAR(9) | Kernel Developer's Manual | MEMBAR(9) |
membar_enter,
membar_exit,
membar_producer,
membar_consumer,
membar_sync,
membar_enter_after_atomic,
membar_exit_before_atomic —
memory access barrier operations
#include
<sys/atomic.h>
void
membar_enter(void);
void
membar_exit(void);
void
membar_producer(void);
void
membar_consumer(void);
void
membar_sync(void);
void
membar_enter_after_atomic(void);
void
membar_exit_before_atomic(void);
The membar set of functions provide an interface for issuing memory barrier access operations with respect to multiple processors in the system.
membar_enter()membar_enter() will reach
global visibility before all loads and stores following it.
membar_enter()
is typically used in code that implements locking primitives to ensure
that a lock protects its data.
membar_exit()membar_exit() will
reach global visibility before any store that follows it.
membar_exit()
is typically used in code that implements locking primitives to ensure
that a lock protects its data.
membar_producer()membar_consumer()membar_sync()membar_enter_after_atomic()membar_enter_after_atomic() will reach global
visibility before all loads and stores following it. The atomic operation
is used to protect the start of a critical section.membar_exit_before_atomic()membar_exit_before_atomic() will reach global
visibility before atomic operation that follows it. The atomic operation
is used to protect the end of a critical section.The atomic operations that can be
used with
membar_enter_after_atomic()
and
membar_exit_before_atomic()
are the atomic_add, atomic_sub, atomic_inc, atomic_dec, and atomic_cas set
of functions. For other cases use membar_enter() or
membar_exit().
membar_enter(),
membar_exit(),
membar_producer(),
membar_consumer(),
membar_sync(),
membar_enter_after_atomic(),
membar_exit_before_atomic() can all be called during
autoconf, from process context, or from interrupt context.
The membar functions first appeared in NetBSD 5.0 and OpenBSD 5.5.
| March 13, 2022 | Debian |