When a thread, T, reads an object at any point in time, the value it sees could be:
- The initial value of the object.
- A value stored by T.
- A value stored by another thread.
And there are memory barriers (Load-Load, Load-Store, Store-Load, and Store-Store), which can be defined as:
<Loads|Stores> before the barrier can't be reordered past the barrier and <Loads|Stores> after the barrier can't get reordered prior to the barrier.
Now, assume that a thread T1 is executing this piece of code:
load(X)
store(Y, 1)
----------- <-- a barrier
load(Y)
store(X, 1)
while another thread, T2, is executing this piece of code:
load(X)
load(Y)
What would be the effect of the barrier in T1 on the visibility of X and Y to thread T2, when the barrier is:
- Load-Load
- Load-Store
- Store-Load
- Store-Store
Thanks!
Aucun commentaire:
Enregistrer un commentaire