C++ Logo

std-discussion

Advanced search

Re: Synchronization of atomic notify and wait

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Tue, 19 Jul 2022 13:28:57 +0200
wt., 19 lip 2022 o 13:09 <language.lawyer_at_[hidden]> napisał(a):
>
> On 19/07/2022 16:00, Marcin Jaczewski wrote:
> > wt., 19 lip 2022 o 12:51 <language.lawyer_at_[hidden]> napisał(a):
> >> On 19/07/2022 15:43, Marcin Jaczewski wrote:
> >>> it's not term but definition that is used further:
> >>
> >> It *is* a term which *has* a definition.
> >>
> >>> "Effects: Unblocks the execution of at least one atomic waiting
> >>> operation on *ptr that is eligible to be unblocked ([atomics.wait]) by
> >>> this call, if any such atomic waiting operations exist."
> >>>
> >>> And now its requirement.
> >>
> >> I don't get how the use of a term makes it (its definition?) a requirement.
> >> BTW, you might have noticed that I've rewritten std::atomic::notify_one /Effects/ using new term /hairy/. std::atomic_ref::notify_one can be changed similarly.
> >
> > Even if you name it X it still holds, "if something is in state X,
> > then will be unblocked". Was `wait` in state X?
> > In previous messages it was clearly show that `wait` was in state X
> > and by specyficacton of `notify` it should be unblock.
>
> There are no doubts that the waiting thread will unblock in https://timsong-cpp.github.io/cppwp/n4861/atomics.types.operations#30.3
> There are doubts that it is guaranteed to see the new value in https://timsong-cpp.github.io/cppwp/n4861/atomics.types.operations#30.1
>
> No, you can't squeeze this guarantee out of the exact textual representation of the term. Neither from its color, weight, smell, taste etc.

But for `notify` explicitly say it NEED to do in that way that `wait`
WILL see it correctly.
The Definition of `wait` on its own is not enough, you need to read
the whole standard and all cross references,
like in the case of `memcpy` that all special guarantees are placed in
multiple places of standard.

Received on 2022-07-19 11:29:09