xref: /openbsd/share/man/man9/membar_sync.9 (revision 3cab2bb3)
1.\" $OpenBSD: membar_sync.9,v 1.3 2014/02/14 05:11:55 dlg 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 $Mdocdate: February 14 2014 $
31.Dt MEMBAR 9
32.Os
33.Sh NAME
34.Nm membar_enter ,
35.Nm membar_exit ,
36.Nm membar_producer ,
37.Nm membar_consumer ,
38.Nm membar_sync
39.Nd memory access barrier operations
40.Sh SYNOPSIS
41.In sys/atomic.h
42.Ft void
43.Fn membar_enter "void"
44.Ft void
45.Fn membar_exit "void"
46.Ft void
47.Fn membar_producer "void"
48.Ft void
49.Fn membar_consumer "void"
50.Ft void
51.Fn membar_sync "void"
52.Sh DESCRIPTION
53The membar set of functions provide an interface for issuing memory barrier
54access operations with respect to multiple processors in the system.
55.Bl -tag -width "mem"
56.It Fn membar_enter
57Any store preceding
58.Fn membar_enter
59will reach global visibility before all loads and stores following it.
60.Pp
61.Fn membar_enter
62is typically used in code that implements locking primitives to ensure
63that a lock protects its data.
64.It Fn membar_exit
65All loads and stores preceding
66.Fn membar_exit
67will reach global visibility before any store that follows it.
68.Pp
69.Fn membar_exit
70is typically used in code that implements locking primitives to ensure
71that a lock protects its data.
72.It Fn membar_producer
73All stores preceding the memory barrier will reach global visibility
74before any stores after the memory barrier reach global visibility.
75.It Fn membar_consumer
76All loads preceding the memory barrier will complete before any loads
77after the memory barrier complete.
78.It Fn membar_sync
79All loads and stores preceding the memory barrier will complete and
80reach global visibility before any loads and stores after the memory
81barrier complete and reach global visibility.
82.El
83.Sh CONTEXT
84.Fn membar_enter ,
85.Fn membar_exit ,
86.Fn membar_producer ,
87.Fn membar_consumer ,
88.Fn membar_sync
89can all be called during autoconf, from process context, or from interrupt context.
90.Sh HISTORY
91The membar functions first appeared in
92.Nx 5.0
93and
94.Ox 5.5 .
95