[BACK]Return to mb.9 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / share / man / man9

File: [cvs.NetBSD.org] / src / share / man / man9 / Attic / mb.9 (download)

Revision 1.6, Sun Jan 2 07:14:02 2011 UTC (13 years, 3 months ago) by jruoho
Branch: MAIN
CVS Tags: yamt-pagecache-tag8, yamt-pagecache-base9, yamt-pagecache-base8, yamt-pagecache-base7, yamt-pagecache-base6, yamt-pagecache-base5, yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, yamt-pagecache, uebayasi-xip-base7, tls-maxphys-base, tls-maxphys, tls-earlyentropy-base, tls-earlyentropy, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3, riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2, prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, pgoyette-localcount-base, pgoyette-localcount-20170426, pgoyette-localcount-20170320, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, pgoyette-localcount, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-8-base, netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2, netbsd-8-0-RC1, netbsd-8, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, matt-nb8-mediatek-base, matt-nb8-mediatek, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus, matt-mips64-premerge-20101231, localcount-20160914, cherry-xenmp-base, cherry-xenmp, bouyer-socketcan-base1, bouyer-socketcan-base, bouyer-socketcan, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2, agc-symver-base, agc-symver
Changes since 1.5: +3 -5 lines

Xref __insn_barrier(3) and mb(9) with each other.

.\"	$NetBSD: mb.9,v 1.6 2011/01/02 07:14:02 jruoho Exp $
.\"
.\" Copyright (c) 2007 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Andrew Doran.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd January 2, 2011
.Dt MB 9
.Os
.Sh NAME
.Nm mb ,
.Nm mb_memory ,
.Nm mb_read ,
.Nm mb_write
.Nd memory barriers
.Sh SYNOPSIS
.In sys/lock.h
.Ft void
.Fn mb_memory "void"
.Ft void
.Fn mb_read "void"
.Ft void
.Fn mb_write "void"
.Sh DESCRIPTION
Many types of processor can execute instructions in a different order
than issued by the compiler or assembler.
On a uniprocessor system, out of order execution is transparent
to the programmer, operating system and applications, as the processor
must ensure that it is self consistent.
.Pp
On multiprocessor systems, out of order execution can present a
problem where locks are not used to guarantee atomicity of
access, because loads and stores issued by any given processor
can appear on the system bus (and thus appear to other processors)
in an unpredictable order.
.Pp
.Fn mb_memory ,
.Fn mb_read ,
and
.Fn mb_write
can be used to control the order in which memory accesses occur, and
thus the order in which those accesses become visible to other processors.
They can be used to implement
.Dq lockless
access to data structures where
the necessary barrier conditions are well understood.
.Pp
Memory barriers can be computationally expensive, as they are
considered
.Dq serializing
operations and may stall further execution
until the processor has drained internal buffers and re-synchronized.
.Pp
The memory barrier primitives control only the order of memory access.
They provide no guarantee that stores have been flushed to the bus, or
that loads have been made from the bus.
.Pp
The memory barrier primitives are guaranteed only to prevent reordering
of accesses to main memory.
They do not provide any guarantee of ordering when used with device
memory (for example, loads or stores to or from a PCI device).
To guarantee ordering of access to device memory, the
.Xr bus_dma 9
and
.Xr bus_space 9
interfaces should be used.
.Sh FUNCTIONS
.Bl -tag -width abcd
.It Fn mb_memory ""
Issue a full memory barrier, ordering all memory accesses.
Causes all loads and stores preceding the call to
.Fn mb_memory
to complete before further memory accesses can be made.
.It Fn mb_read ""
Issue a read memory barrier, ordering all loads from memory.
Causes all loads preceding the call to
.Fn mb_read
to complete before further loads can be made.
Stores may be reordered ahead of or behind a call to
.Fn mb_read .
.It Fn mb_write ""
Issue a write memory barrier, ordering all stores to memory.
Causes all stores preceding the call to
.Fn mb_write
to complete before further stores can be made.
Loads may be reordered ahead of or behind a call to
.Fn mb_write .
.El
.Sh SEE ALSO
.Xr __insn_barrier 3 ,
.Xr bus_dma 9 ,
.Xr bus_space 9 ,
.Xr mutex 9 ,
.Xr rwlock 9
.Sh HISTORY
The memory barrier primitives first appeared in
.Nx 5.0 .