xref: /netbsd-src/lib/libc/atomic/membar_ops.3 (revision 6a493d6bc668897c91594964a732d38505b70cbb)
1.\"	$NetBSD: membar_ops.3,v 1.3 2011/04/28 11:56:26 wiz Exp $
2.\"
3.\" Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Jason R. Thorpe.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in the
16.\" documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd February 11, 2007
31.Dt MEMBAR_OPS 3
32.Os
33.Sh NAME
34.Nm membar_ops ,
35.Nm membar_enter ,
36.Nm membar_exit ,
37.Nm membar_producer ,
38.Nm membar_consumer ,
39.Nm membar_sync
40.Nd memory access barrier operations
41.\" .Sh LIBRARY
42.\" .Lb libc
43.Sh SYNOPSIS
44.In sys/atomic.h
45.\"
46.Ft void
47.Fn membar_enter "void"
48.Ft void
49.Fn membar_exit "void"
50.Ft void
51.Fn membar_producer "void"
52.Ft void
53.Fn membar_consumer "void"
54.Ft void
55.Fn membar_sync "void"
56.Sh DESCRIPTION
57The
58.Nm membar_ops
59family of functions provide memory access barrier operations necessary
60for synchronization in multiprocessor execution environments that have
61relaxed load and store order.
62.Pp
63.Bl -tag -width "mem"
64.It Fn membar_enter
65Any store preceding
66.Fn membar_enter
67will reach global visibility before all loads and stores following it.
68.Pp
69.Fn membar_enter
70is typically used in code that implements locking primitives to ensure
71that a lock protects its data.
72.It Fn membar_exit
73All loads and stores preceding
74.Fn membar_exit
75will reach global visibility before any store that follows it.
76.Pp
77.Fn membar_exit
78is typically used in code that implements locking primitives to ensure
79that a lock protects its data.
80.It Fn membar_producer
81All stores preceding the memory barrier will reach global visibility
82before any stores after the memory barrier reach global visibility.
83.It Fn membar_consumer
84All loads preceding the memory barrier will complete before any loads
85after the memory barrier complete.
86.It Fn membar_sync
87All loads and stores preceding the memory barrier will complete and
88reach global visibility before any loads and stores after the memory
89barrier complete and reach global visibility.
90.El
91.Sh SEE ALSO
92.Xr atomic_ops 3
93.Sh HISTORY
94The
95.Nm membar_ops
96functions first appeared in
97.Nx 5.0 .
98