C++ Logo

std-discussion

Advanced search

Re: Data races

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Tue, 7 Mar 2023 17:52:07 +0100
wt., 7 mar 2023 o 12:03 Vladimir Grigoriev via Std-Discussion
<std-discussion_at_[hidden]> napisał(a):
>
> But in the paragraph #10 there is written that
>
> 10 An evaluation A happens before an evaluation B (or, equivalently, B happens after A) if:
> (10.1) — A is sequenced before B, or
> (10.2) — A inter-thread happens before B.
>
> does not it already mean that «A shall be earlier than B»?

No, if it was not an atomic variable, it could have any order
(especially if you do not have correct atomic guarantees),
besides you do not quote too "in the modification order of M" and this
is a critical part of this text.
As Jason said "happens before" and "modification order of" are
separate things that
are linked together by this.

>
> With best regards
> (Vlad from Moscow)
>
> You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
>
>
>
> Вторник, 7 марта 2023, 1:31 +03:00 от Jason McKesson via Std-Discussion <std-discussion_at_[hidden]>:
>
> On Mon, Mar 6, 2023 at 3:40PM Vladimir Grigoriev via Std-Discussion
> <std-discussion_at_[hidden]> wrote:
> >
> > In the paragraph #15 of section 6.9.2.2 Data races of the C++20 Standard there is written
> >
> > «15 If an operation A that modifies an atomic object M happens before an operation B that modifies M, then A shall be earlier than B in the modification order of M.»
> >
> > Is not it just a tautology?
>
> That's only because you're assuming what "happens before" means based
> on the literal words. Previously, the standard explained under what
> circumstances "happens before" takes place. This sentence explains
> what "happens before" actually *does*.
>
> Until this sentence, the atomic "modification order" has been a
> concept wholly separate from "happens before". This sentence connects
> them.
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
>
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

Received on 2023-03-07 16:52:20