membarrier —
memory barrier
Standard C Library (libc, -lc)
#include
<sys/membarrier.h>
int
membarrier(int
cmd, unsigned
flags, int
cpu_id);
If the cmd is
MEMBARRIER_CMD_QUERY a bitmask of supported commands
is returned. Otherwise, on success, membarrier
returns 0. On error, -1 is returned and errno is set
to indicate the error.
membarrier may fail with the following
errors:
- [
EINVAL]
- cmd does not specify a valid command.
- [
EINVAL]
- flags is not 0.
- [
EPERM]
- An attempt was made to use
MEMBARRIER_CMD_GLOBAL_EXPEDITED,
MEMBARRIER_CMD_PRIVATE_EXPEDITED, or
MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE by a
process that did not previously register use with the corresponding
MEMBARRIER_CMD_REGISTER_*
cmd.
The membarrier system call originated in
Linux. This implementation aims to be source-compatible with the Linux
implementation. Certain cmd and
flags values are currently not supported by
FreeBSD.
The membarrier function was introduced in
FreeBSD 14.1.