1.\" $NetBSD: membar_ops.3,v 1.1 2008/06/23 10:22:40 ad 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 Febuary 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 65.Pp 66Any store preceeding 67.Fn membar_enter 68will reach global visibility before all loads and stores following it. 69.Pp 70.Fn membar_enter 71is typically used in code that implements locking primitives to ensure 72that a lock protects its data. 73.It Fn membar_exit 74.Pp 75All loads and stores preceding 76.Fn membar_exit 77will reach global visibility before any store that follows it. 78.Pp 79.Fn membar_exit 80is typically used in code that implements locking primitives to ensure 81that a lock protects its data. 82.It Fn membar_producer 83.Pp 84All stores preceding the memory barrier will reach global visibility 85before any stores after the memory barrier reach global visibility. 86.It Fn membar_consumer 87.Pp 88All loads preceding the memory barrier will complete before any loads 89after the memory barrier complete. 90.It Fn membar_sync 91.Pp 92All loads and stores preceding the memory barrier will complete and 93reach global visibility before any loads and stores after the memory 94barrier complete and reach global visibility. 95.El 96.Sh SEE ALSO 97.Xr atomic_ops 3 98.Sh HISTORY 99The 100.Nm membar_ops 101functions first appeared in 102.Nx 5.0 . 103