Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 15 Jun 2021 17:09:01 -0700
From:      "Ronald F. Guilmette" <rfg@tristatelogic.com>
To:        freeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: Is a successful call to write(2) atomic?
Message-ID:  <26258.1623802141@segfault.tristatelogic.com>
In-Reply-To: <CAFbbPugCir436Z6cHyOZBtRAQ0on0eFfYc0Z0xNrhHCRW3r=4A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In message <CAFbbPugCir436Z6cHyOZBtRAQ0on0eFfYc0Z0xNrhHCRW3r=3D4A@mail.gma=
il.com>
Paul Procacci <pprocacci@gmail.com> wrote:

>It now reads:
>
>This volume of POSIX.1-2017 does not specify the behavior of concurrent
>writes to a regular file from multiple threads, except that each write is
>atomic (see *Thread Interactions with Regular File Operations*
><https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.htm=
l#tag_15_09_07>).
>Applications should use some form of concurrency control.
>
>In both cases, it states:  "Applications should use some form of
>concurrency control".

Sigh.  The above (revised) verbage isn't my personal idea of unambiguous
clarity.  I mean it isn't even clear what -they- mean by "atomic" in this
context.  They may intend it to mean exactly what I have been using it
to mean here, but if I have learned anything about Posix, it is that their
documents are sometimes subtle in their use of terminology.  (I sustained
some serious verbal abuse on one Posix mailing list some months ago for
my failure to fully appreciate this.)

More to the point, if indeed each call to write() *is* "atomic"... at leas=
t
in the sense that the given buffer will be treated like an indivisable who=
le,
all of the way along its journey to some physical device... then why are
users nontheless being encouraged, still, to "use some form of concurrency
control"?  I mean what would be the point of that if in fact write() never
busts up the hunks of data given to it into separate sub-hunks?

Sounds to me like they are saying "Here, we are giving you this belt, but
we advise you to wear your suspenders also, just in case."

This seems goofy on the face of it.


Regards,
rfg


P.s.  Thanks Paul, for researching the relevant Posix pronouncements.



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