Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Oct 2017 08:25:24 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r325130 - stable/11/share/man/man9
Message-ID:  <201710300825.v9U8POho049030@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Oct 30 08:25:24 2017
New Revision: 325130
URL: https://svnweb.freebsd.org/changeset/base/325130

Log:
  MFC r324926:
  Expand explanation of atomicity.

Modified:
  stable/11/share/man/man9/atomic.9
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/share/man/man9/atomic.9
==============================================================================
--- stable/11/share/man/man9/atomic.9	Mon Oct 30 08:23:48 2017	(r325129)
+++ stable/11/share/man/man9/atomic.9	Mon Oct 30 08:25:24 2017	(r325130)
@@ -23,7 +23,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd Jan 3, 2017
+.Dd March 23, 2017
 .Dt ATOMIC 9
 .Os
 .Sh NAME
@@ -76,10 +76,41 @@
 .Ft int
 .Fn atomic_testandset_<type> "volatile <type> *p" "u_int v"
 .Sh DESCRIPTION
-Each of the atomic operations is guaranteed to be atomic across multiple
-threads and in the presence of interrupts.
-They can be used to implement reference counts or as building blocks for more
-advanced synchronization primitives such as mutexes.
+All of these operations are performed atomically across multiple
+threads and in the presence of interrupts, meaning that they are               
+performed in an indivisible manner from the perspective of concurrently
+running threads and interrupt handlers.
+.Pp
+When atomic operations are performed on cache-coherent memory, all
+operations on the same location are totally ordered.
+.Pp
+When an atomic load is performed on a location in cache-coherent memory,
+it reads the entire value that was defined by the last atomic store to
+each byte of the location.
+An atomic load will never return a value out of thin air.
+When an atomic store is performed on a location, no other thread or
+interrupt handler will observe a
+.Em torn write ,
+or partial modification of the location.
+.Pp
+On all architectures supported by
+.Fx ,
+ordinary loads and stores of naturally aligned integer types
+are atomic, as executed by the processor.
+.Pp
+Atomic operations can be used to implement reference counts or as
+building blocks for synchronization primitives such as mutexes.
+.Pp
+The semantics of
+.Fx Ns 's
+atomic operations are almost identical to those of the similarly named
+C11 operations.
+The one important difference is that the C11 standard does not
+require ordinary loads and stores to ever be atomic.
+This is is why the
+.Fn atomic_load_explicit memory_order_relaxed
+operation exists in the C11 standard, but is not provided by
+.In machine/atomic.h .
 .Ss Types
 Each atomic operation operates on a specific
 .Fa type .



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710300825.v9U8POho049030>