Does seq_cst guarantee immediate visibility?

N3243 1.10.21 says

It can be shown that programs that correctly use mutexes and memory_order_ seq_cst to prevent all data exploration and use any other synchronization operations behave as if the operations performed by their constituent threads were simply interleaving, with each computation of the value of the object being taken from the last side effect on this object in this interlace. This is commonly referred to as "sequential consistency".

Does this mean that any seq_cst entry on an atomic object is immediately visible to other threads that read the atomic object with the order seq_cst ?

+3


source to share


1 answer


No, there is nothing in the C ++ standard that guarantees direct visibility.

Atomic records should become visible to other streams within a "reasonable" period of time, but they should not be immediate and there is no precise definition of "reasonable".



Guarantee is that there is one general order of operations memory_order_seq_cst

. Therefore, a read that does not see that the written value must occur earlier in this general order than the write. Since this general order includes all variables and all memory_order_seq_cst

operations, if there is any relationship between threads at all, records should appear quickly.

+6


source







All Articles