1
比方說,我有兩個線程(T1,T2)共享的變量A,B和C.
我有以下代碼:隱式內存障礙
//T1
//~~
A = 1;
B = 1;
C = 1;
InterlockedExchange(ref Foo, 1);
//T2 (executes AFTER T1 calls InterlockedExchange)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InterlockedExchange(ref Bar, 1);
WriteLine(A);
WriteLine(B);
WriteLine(C);
問:
確實在T1和T2調用InterlockedExchange(隱式全柵欄),gurentess是T2將 「看」 柵欄前通過T1完成寫? (A,B和C變量),儘管這些變量不在Foo和Bar?