Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how the right thread should be reordered in order for the assertion to fail?(slide 30) #383

Closed
Shynar88 opened this issue Oct 12, 2019 · 3 comments

Comments

@Shynar88
Copy link

From slide 30:
Screen Shot 2019-10-12 at 16 55 26
"Assertion failure due to reordering in the left thread or in the right thread"
In the case of the left thread reordering, I can see why assertion fails(1)FLAG.store(1); 2)right thread 3)DATA = 42;). However, I cannot imagine how the right thread should be reordered in order for the assertion to fail?

Thank you!

@jeehoonkang
Copy link
Member

Reading from DATA is reordered before reading from FLAG. It's actually observable in some architectures which perform branch speculation.

@Shynar88
Copy link
Author

Shynar88 commented Oct 13, 2019

Does this mean that assert(DATA) == 42 can be executed irrespectively of the condition of FLAG.load()? Doesn't this kind of reordering break the logic of the program, and thus shouldn't be allowed by the compiler?

@jeehoonkang
Copy link
Member

No, the loading from DATA alone can be reordered. Assertion on the loaded value, as you explained, cannot be reordered before the loading from FLAG.

@kyeongmincho kyeongmincho transferred this issue from kaist-cp/helpdesk Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants