From owner-svn-src-stable-11@freebsd.org Mon Oct 30 08:25:25 2017 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA98DE57367; Mon, 30 Oct 2017 08:25:25 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 88B967D4CD; Mon, 30 Oct 2017 08:25:25 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9U8POeb049031; Mon, 30 Oct 2017 08:25:24 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9U8POho049030; Mon, 30 Oct 2017 08:25:24 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201710300825.v9U8POho049030@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Mon, 30 Oct 2017 08:25:24 +0000 (UTC) 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 X-SVN-Group: stable-11 X-SVN-Commit-Author: kib X-SVN-Commit-Paths: stable/11/share/man/man9 X-SVN-Commit-Revision: 325130 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Oct 2017 08:25:25 -0000 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_ "volatile *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 .