C++ Logo

std-discussion

Advanced search

Re: Fwd: Synchronization of atomic notify and wait

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Thu, 21 Jul 2022 01:10:25 +0200
czw., 21 lip 2022 o 01:00 Thiago Macieira via Std-Discussion
<std-discussion_at_[hidden]> napisaƂ(a):
>
> On Wednesday, 20 July 2022 15:44:56 PDT Marcin Jaczewski via Std-Discussion
> wrote:
> > Then it needs use that flush/update for every operation to maintain
> > C++ memory model.
>
> Not really. C++ does not say anything about the timing of when changes are
> made visible from one thread to another, only about the coherency of the
> happens-before sequence and what is required to be observable if other
> happenings have been observed.
>
> It's perfectly valid for a lone operation on an atomic to sit on one core's
> cache for a century and never be observed by any other, so long as this atomic
> is updated again by any other.
>

https://timsong-cpp.github.io/cppwp/n4861/intro.multithread#intro.progress-18
https://timsong-cpp.github.io/cppwp/n4861/atomics.order#11

This both limits this will not be a century. but some short time could
still be possible.

This gives me the idea that `notyfy` could itself block for a longer
time than is needed to propagate
stored value and then unblock others and this could be a solution for
the problem in the initial email.

Received on 2022-07-20 23:10:37