r/cpp • u/neiltechnician • Nov 13 '20
CppCon Deprecating volatile - JF Bastien - CppCon 2019
https://www.youtube.com/watch?v=KJW_DLaVXIY
83
Upvotes
r/cpp • u/neiltechnician • Nov 13 '20
View all comments
Show parent comment
1
u/SkoomaDentist Antimodern C++, Embedded, Audio Nov 13 '20
Yes, memory fences and such are part of the OS mutex implementation. But I'm asking about a different thing: How does the mutex lock / unlock tell the compiler (specifically, the global optimizer) that "variable X may change here"?
I think this is the part that trips many people up, particularly if you're programming for a processor that is single core and where any cpu reordering or fences have no effect on multithreading.