GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
MEMBARRIER(2) FreeBSD System Calls Manual MEMBARRIER(2)

membarriermemory barrier

Standard C Library (libc, -lc)

#include <sys/membarrier.h>

int
membarrier(int cmd, unsigned flags, int cpu_id);

The membarrier system call provides a memory barrier, ensuring ordering between memory accesses performed by different threads or processes within the same address space.

The following values for cmd may be specified:

Query supported commands. A bitmask of commands supported by the kernel is returned.
Issue a memory barrier for all threads from all processes.
This is an alias for MEMBARRIER_CMD_GLOBAL.
Execute a memory barrier on all running threads of all processes registered with MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED.
Register the process to receive MEMBARRIER_CMD_GLOBAL_EXPEDITED memory barriers.
Execute a memory barrier on each running thread belonging to the same process as the thread calling membarrier.
Register the process to receive MEMBARRIER_CMD_PRIVATE_EXPEDITED memory barriers.
In addition to the guarantees provided by MEMBARRIER_CMD_PRIVATE_EXPEDITED it also executes machine-specific serialization instructions, which ensures that all possible speculative and out-of-order activities on the target CPU are fenced.
Register the process to receive MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE memory barriers.

The following cmd values are defined for source compatibility but are not yet supported:

 
 

The flags argument must be 0. The cpu_id argument is ignored.

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:

[]
cmd does not specify a valid command.
[]
flags is not 0.
[]
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.

October 6, 2024 FreeBSD 14.3-RELEASE

Search for    or go to Top of page |  Section 2 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.