admin管理员组文章数量:1122832
I learned some information related to C++ memory_order from , but I found some content that confused me a bit:
Visible side-effects The side-effect A on a scalar M (a write) is visible with respect to value computation > B on M (a read) if both of the following are true:
- A happens-before B.
- There is no other side effect X to M where A happens-before X and X happens-before B.
This literature mentions visible side effects, meaning that a side effect A can be seen by another thread's read operation B, and one of the conditions for this is that A happens-before B.
For instance, if A is a relaxed order write to an atomic variable M, and B is a relaxed order read from M, it is evident that if the conditions are right, B can certainly read A. So can we say that A happens-before B in this case?
However, in the literature regarding the happens-before relationship, it mainly refers to inter-thread happens-before, which is based on the conditions established by either synchronizes-with or dependency-ordered-before relationships. Clearly, since both the read and write operations are in relaxed order, they do not fall within these two relationship categories.
Yet, visible side effects must satisfy the happens-before relationship, which I find very contradictory.
Is there a problem with my understanding, or is the literature I read not comprehensive enough? Thank you.
I would like to know if there is a problem with my understanding of visible side effects and the happens-before relationship, and where the problem might be.
本文标签: C Visible SideEffect and HappensBefore RelationStack Overflow
版权声明:本文标题:C++ Visible Side-Effect and Happens-Before Relation - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736304797a1932361.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论