Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is there a distinct "inter-thread happens before" relation defined in ISO/IEC 14882:2011?

§ 1.10.11 of ISO/IEC 14882:2011 (C++ 11) defines the "inter-thread happens before" relation between evaluations, whose only difference from the "happens before" relation in § 1.10.12 is that A happens before B if A is sequenced before B but that is not sufficient for A inter-thread happens before B. Why is "inter-thread happens before" important enough to warrant a separate definition?

A note in § 1.10.11 suggests that "inter-thread happens before" doesn't allow evaluations whose only relation is "sequenced before" in part

to permit “inter-thread happens before” to be transitively closed

What does that mean? I know what a transitive closure is, and I know what it means for a set to be closed over some operation, but I've never heard of "transitively closed" and both Google and context are failing me.

like image 683
Shea Levy Avatar asked Feb 01 '26 04:02

Shea Levy


2 Answers

"Inter-thread happens before" is defined purely for exposition. Note how "happens before" is defined as "sequenced before or inter-thread happens before", and the notion of "inter-thread happens before" is not used for anything else. "Sequenced before" describes evaluations happening on the same thread, "inter-thread happens before" applies to evaluations happening on different threads; "happens before" combines the two.

like image 105
Igor Tandetnik Avatar answered Feb 03 '26 16:02

Igor Tandetnik


The "transitively closed" remark simply means that the relation is transitive: if A inter-thread happens before B and B inter-thread happens before C, then A inter-thread happens before C.

That property doesn't hold if "sequenced before" alone qualifies as "inter-thread happens before" because of the first exclusion (of sequences ending in "dependency-ordered before" followed by "sequenced before").

This also means that "happens before" is not transitive; if A happens before B and B happens before C, it doesn't necessarily follow that A happens before C.

like image 36
T.C. Avatar answered Feb 03 '26 18:02

T.C.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!