Because part of this question wasn't addressed, I'm making it a separate question:
#include<iostream>
#include<thread>
using namespace std;
void f2(double* ret) {
*ret=5.;
}
int main() {
double ret=0.;
thread t2(f2, &ret);
t2.join();
cout << "ret=" << ret << endl;
}
Is this program data race free?
Are there any guarantees, with respect to new C++ memory model, that accesses to variable ret from thread t2 and thread main are synchronized?
I mean, it is obvious that accesses from t2 and main won't collide if the program is executed on the same core.
But what if t2 and main are executed on different cores?
Are there any guarantees that core's caches will synchronize before main continues execution?
I'd appreciate if somebody could provide same references.
Thank you.