# SOME DESCRIPTIVE TITLE # Copyright (C) YEAR Free Software Foundation, Inc. # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2026-06-05 06:30+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. type: TH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "membarrier" msgstr "" #. type: TH #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 #: opensuse-tumbleweed #, no-wrap msgid "2025-09-21" msgstr "" #. type: TH #: archlinux debian-unstable #, no-wrap msgid "Linux man-pages 6.18" msgstr "" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "NAME" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "membarrier - issue memory barriers on a set of threads" msgstr "" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "LIBRARY" msgstr "" #. type: Plain text #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron #: opensuse-leap-16-1 opensuse-tumbleweed msgid "Standard C library (I,\\ I<-lc>)" msgstr "" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "SYNOPSIS" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "" "B<#include Elinux/membarrier.hE> /* Definition of B constants */\n" "B<#include Esys/syscall.hE> /* Definition of B constants */\n" "B<#include Eunistd.hE>\n" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "BIB<, unsigned int >IB<, int >IB<);>\n" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "I: glibc provides no wrapper for B(), necessitating the " "use of B(2)." msgstr "" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "DESCRIPTION" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The B() system call helps reducing the overhead of the memory " "barrier instructions required to order memory accesses on multi-core " "systems. However, this system call is heavier than a memory barrier, so " "using it effectively is I as simple as replacing memory barriers with " "this system call, but requires understanding of the details below." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Use of memory barriers needs to be done taking into account that a memory " "barrier always needs to be either matched with its memory barrier " "counterparts, or that the architecture's memory model doesn't require the " "matching barriers." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "There are cases where one side of the matching barriers (which we will refer " "to as \"fast side\") is executed much more often than the other (which we " "will refer to as \"slow side\"). This is a prime target for the use of " "B(). The key idea is to replace, for these matching barriers, " "the fast-side memory barriers by simple compiler barriers, for example:" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "asm volatile (\"\" : : : \"memory\")\n" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "and replace the slow-side memory barriers by calls to B()." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "This will add overhead to the slow side, and remove overhead from the fast " "side, thus resulting in an overall performance increase as long as the slow " "side is infrequent enough that the overhead of the B() calls " "does not outweigh the performance gain on the fast side." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "The I argument is one of the following:" msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.3)" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Query the set of supported commands. The return value of the call is a bit " "mask of supported commands. B, which has the value 0, " "is not itself included in this bit mask. This command is always supported " "(on kernels where B() is provided)." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.16)" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Ensure that all threads from all processes on the system pass through a " "state where all memory accesses to user-space addresses match program order " "between entry to and return from the B() system call. All " "threads on the system are targeted by this command." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.16)" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Execute a memory barrier on all running threads of all processes that " "previously registered with B." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Upon return from the system call, the calling thread has a guarantee that " "all running threads have passed through a state where all memory accesses to " "user-space addresses match program order between entry to and return from " "the system call (non-running threads are de facto in such a state). This " "guarantee is provided only for the threads of processes that previously " "registered with B." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Given that registration is about the intent to receive the barriers, it is " "valid to invoke B from a process that has " "not employed B." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The \"expedited\" commands complete faster than the non-expedited ones; they " "never block, but have the downside of causing extra overhead." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.16)" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Register the process's intent to receive B " "memory barriers." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.14)" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Execute a memory barrier on each running thread belonging to the same " "process as the calling thread." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Upon return from the system call, the calling thread has a guarantee that " "all its running thread siblings have passed through a state where all memory " "accesses to user-space addresses match program order between entry to and " "return from the system call (non-running threads are de facto in such a " "state). This guarantee is provided only for threads in the same process as " "the calling thread." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "A process must register its intent to use the private expedited command " "prior to using it." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.14)" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Register the process's intent to use B." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.16)" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "In addition to providing the memory ordering guarantees described in " "B, upon return from system call the " "calling thread has a guarantee that all its running thread siblings have " "executed a core serializing instruction. This guarantee is provided only " "for threads in the same process as the calling thread." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The \"expedited\" commands complete faster than the non-expedited ones, they " "never block, but have the downside of causing extra overhead." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "A process must register its intent to use the private expedited sync core " "command prior to using it." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.16)" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Register the process's intent to use " "B." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 5.10)" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Ensure the caller thread, upon return from system call, that all its running " "thread siblings have any currently running rseq critical sections restarted " "if I parameter is 0; if I parameter is " "B, then this operation is performed only on CPU " "indicated by I. This guarantee is provided only for threads in the " "same process as the calling thread." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "RSEQ membarrier is only available in the \"private expedited\" form." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "A process must register its intent to use the private expedited rseq command " "prior to using it." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 5.10)" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Register the process's intent to use " "B." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B (since Linux 4.3)" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "This is an alias for B that exists for header " "backward compatibility." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The I argument must be specified as 0 unless the command is " "B, in which case I can be " "either 0 or B." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The I argument is ignored unless I is " "B, in which case it must specify the CPU targeted " "by this membarrier command." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "All memory accesses performed in program order from each targeted thread are " "guaranteed to be ordered with respect to B()." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "If we use the semantic I to represent a compiler barrier forcing " "memory accesses to be performed in program order across the barrier, and " "I to represent explicit memory barriers forcing full memory " "ordering across the barrier, we have the following ordering table for each " "pairing of I, B(), and I. The pair " "ordering is detailed as (O: ordered, X: not ordered):" msgstr "" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "barrier()" msgstr "" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "smp_mb()" msgstr "" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "membarrier()" msgstr "" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "X" msgstr "" #. type: tbl table #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "O" msgstr "" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "RETURN VALUE" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "On success, the B operation returns a bit mask of " "supported commands, and the B, " "B, " "B, " "B, " "B, " "B, and " "B operations return " "zero. On error, -1 is returned, and I is set to indicate the error." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "For a given command, with I set to 0, this system call is guaranteed " "to always return the same value until reboot. Further calls with the same " "arguments will lead to the same result. Therefore, with I set to 0, " "error handling is required only for the first call to B()." msgstr "" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "ERRORS" msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "I is invalid, or I is nonzero, or the B " "command is disabled because the I CPU parameter has been set, or " "the B and " "B commands are not " "implemented by the architecture." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "The B() system call is not implemented by this kernel." msgstr "" #. type: TP #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "B" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "The current process was not registered prior to using private expedited " "commands." msgstr "" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "STANDARDS" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "Linux." msgstr "" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "HISTORY" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "Linux 4.3." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "Before Linux 5.10, the prototype was:" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "BIB<, int >IB<);>\n" msgstr "" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "NOTES" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "A memory barrier instruction is part of the instruction set of architectures " "with weakly ordered memory models. It orders memory accesses prior to the " "barrier and after the barrier with respect to matching barriers on other " "cores. For instance, a load fence can order loads prior to and following " "that fence with respect to stores ordered by store fences." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Program order is the order in which instructions are ordered in the program " "assembly code." msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Examples where B() can be useful include implementations of " "Read-Copy-Update libraries and garbage collectors." msgstr "" #. type: SH #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "EXAMPLES" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "" "Assuming a multithreaded application where \"fast_path()\" is executed very " "frequently, and where \"slow_path()\" is executed infrequently, the " "following code (x86) can be transformed using B():" msgstr "" #. type: Plain text #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 #: opensuse-tumbleweed #, no-wrap msgid "" "#include Estdlib.hE\n" "\\&\n" "static volatile int a, b;\n" "\\&\n" "static void\n" "fast_path(int *read_b)\n" "{\n" " a = 1;\n" " asm volatile (\"mfence\" : : : \"memory\");\n" " *read_b = b;\n" "}\n" "\\&\n" "static void\n" "slow_path(int *read_a)\n" "{\n" " b = 1;\n" " asm volatile (\"mfence\" : : : \"memory\");\n" " *read_a = a;\n" "}\n" "\\&\n" "int\n" "main(void)\n" "{\n" " int read_a, read_b;\n" "\\&\n" " /*\n" " * Real applications would call fast_path() and slow_path()\n" " * from different threads. Call those from main() to keep\n" " * this example short.\n" " */\n" "\\&\n" " slow_path(&read_a);\n" " fast_path(&read_b);\n" "\\&\n" " /*\n" " * read_b == 0 implies read_a == 1 and\n" " * read_a == 0 implies read_b == 1.\n" " */\n" "\\&\n" " if (read_b == 0 && read_a == 0)\n" " abort();\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. type: Plain text #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed msgid "The code above transformed to use B() becomes:" msgstr "" #. type: Plain text #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1 #: opensuse-tumbleweed #, no-wrap msgid "" "#define _GNU_SOURCE\n" "#include Estdlib.hE\n" "#include Estdio.hE\n" "#include Eunistd.hE\n" "#include Esys/syscall.hE\n" "#include Elinux/membarrier.hE\n" "\\&\n" "static volatile int a, b;\n" "\\&\n" "static int\n" "membarrier(int cmd, unsigned int flags, int cpu_id)\n" "{\n" " return syscall(__NR_membarrier, cmd, flags, cpu_id);\n" "}\n" "\\&\n" "static int\n" "init_membarrier(void)\n" "{\n" " int ret;\n" "\\&\n" " /* Check that membarrier() is supported. */\n" "\\&\n" " ret = membarrier(MEMBARRIER_CMD_QUERY, 0, 0);\n" " if (ret E 0) {\n" " perror(\"membarrier\");\n" " return -1;\n" " }\n" "\\&\n" " if (!(ret & MEMBARRIER_CMD_GLOBAL)) {\n" " fprintf(stderr,\n" " \"membarrier does not support MEMBARRIER_CMD_GLOBAL\\[rs]n\");\n" " return -1;\n" " }\n" "\\&\n" " return 0;\n" "}\n" "\\&\n" "static void\n" "fast_path(int *read_b)\n" "{\n" " a = 1;\n" " asm volatile (\"\" : : : \"memory\");\n" " *read_b = b;\n" "}\n" "\\&\n" "static void\n" "slow_path(int *read_a)\n" "{\n" " b = 1;\n" " membarrier(MEMBARRIER_CMD_GLOBAL, 0, 0);\n" " *read_a = a;\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int read_a, read_b;\n" "\\&\n" " if (init_membarrier())\n" " exit(EXIT_FAILURE);\n" "\\&\n" " /*\n" " * Real applications would call fast_path() and slow_path()\n" " * from different threads. Call those from main() to keep\n" " * this example short.\n" " */\n" "\\&\n" " slow_path(&read_a);\n" " fast_path(&read_b);\n" "\\&\n" " /*\n" " * read_b == 0 implies read_a == 1 and\n" " * read_a == 0 implies read_b == 1.\n" " */\n" "\\&\n" " if (read_b == 0 && read_a == 0)\n" " abort();\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. type: TH #: debian-trixie #, no-wrap msgid "2024-06-15" msgstr "" #. type: TH #: debian-trixie #, no-wrap msgid "Linux man-pages 6.9.1" msgstr "" #. type: Plain text #: debian-trixie msgid "Standard C library (I, I<-lc>)" msgstr "" #. type: Plain text #: debian-trixie fedora-44 fedora-rawhide #, no-wrap msgid "" "#include Estdlib.hE\n" "\\&\n" "static volatile int a, b;\n" "\\&\n" "static void\n" "fast_path(int *read_b)\n" "{\n" " a = 1;\n" " asm volatile (\"mfence\" : : : \"memory\");\n" " *read_b = b;\n" "}\n" "\\&\n" "static void\n" "slow_path(int *read_a)\n" "{\n" " b = 1;\n" " asm volatile (\"mfence\" : : : \"memory\");\n" " *read_a = a;\n" "}\n" "\\&\n" "int\n" "main(void)\n" "{\n" " int read_a, read_b;\n" "\\&\n" " /*\n" " * Real applications would call fast_path() and slow_path()\n" " * from different threads. Call those from main() to keep\n" " * this example short.\n" " */\n" "\\&\n" " slow_path(&read_a);\n" " fast_path(&read_b);\n" "\\&\n" " /*\n" " * read_b == 0 implies read_a == 1 and\n" " * read_a == 0 implies read_b == 1.\n" " */\n" "\\&\n" " if (read_b == 0 && read_a == 0)\n" " abort();\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. type: Plain text #: debian-trixie fedora-44 fedora-rawhide #, no-wrap msgid "" "#define _GNU_SOURCE\n" "#include Estdlib.hE\n" "#include Estdio.hE\n" "#include Eunistd.hE\n" "#include Esys/syscall.hE\n" "#include Elinux/membarrier.hE\n" "\\&\n" "static volatile int a, b;\n" "\\&\n" "static int\n" "membarrier(int cmd, unsigned int flags, int cpu_id)\n" "{\n" " return syscall(__NR_membarrier, cmd, flags, cpu_id);\n" "}\n" "\\&\n" "static int\n" "init_membarrier(void)\n" "{\n" " int ret;\n" "\\&\n" " /* Check that membarrier() is supported. */\n" "\\&\n" " ret = membarrier(MEMBARRIER_CMD_QUERY, 0, 0);\n" " if (ret E 0) {\n" " perror(\"membarrier\");\n" " return -1;\n" " }\n" "\\&\n" " if (!(ret & MEMBARRIER_CMD_GLOBAL)) {\n" " fprintf(stderr,\n" " \"membarrier does not support MEMBARRIER_CMD_GLOBAL\\[rs]n\");\n" " return -1;\n" " }\n" "\\&\n" " return 0;\n" "}\n" "\\&\n" "static void\n" "fast_path(int *read_b)\n" "{\n" " a = 1;\n" " asm volatile (\"\" : : : \"memory\");\n" " *read_b = b;\n" "}\n" "\\&\n" "static void\n" "slow_path(int *read_a)\n" "{\n" " b = 1;\n" " membarrier(MEMBARRIER_CMD_GLOBAL, 0, 0);\n" " *read_a = a;\n" "}\n" "\\&\n" "int\n" "main(int argc, char *argv[])\n" "{\n" " int read_a, read_b;\n" "\\&\n" " if (init_membarrier())\n" " exit(EXIT_FAILURE);\n" "\\&\n" " /*\n" " * Real applications would call fast_path() and slow_path()\n" " * from different threads. Call those from main() to keep\n" " * this example short.\n" " */\n" "\\&\n" " slow_path(&read_a);\n" " fast_path(&read_b);\n" "\\&\n" " /*\n" " * read_b == 0 implies read_a == 1 and\n" " * read_a == 0 implies read_b == 1.\n" " */\n" "\\&\n" " if (read_b == 0 && read_a == 0)\n" " abort();\n" "\\&\n" " exit(EXIT_SUCCESS);\n" "}\n" msgstr "" #. type: TH #: fedora-44 fedora-rawhide #, no-wrap msgid "2024-07-23" msgstr "" #. type: TH #: fedora-44 fedora-rawhide #, no-wrap msgid "Linux man-pages 6.13" msgstr "" #. type: TH #: mageia-cauldron #, no-wrap msgid "Linux man-pages 6.17" msgstr "" #. type: TH #: opensuse-leap-16-1 opensuse-tumbleweed #, no-wrap msgid "Linux man-pages (unreleased)" msgstr ""