According to this http://ift.tt/1bPCDnm, a released store is implemented as MOV (into memory).
According to his http://ift.tt/1krieqi
memory_order_release:
A store operation with this memory order performs the release operation: no memory accesses in the current thread can be reordered after this store. This ensures that all writes in the current thread are visible in other threads that acquire or the same atomic variable and writes that carry a dependency into the atomic variable become visible in other threads that consume the same atomic.
I understand that memory_order_release so that when used, all memory stores done previously should finish before this one.
int a;
a = 10;
std::atomic<int> b;
b.store(50, std::memory_order_release); // i can be sure that 'a' is already 10, so processor can't reorder the stores to 'a' and 'b'
QUESTION: how is it possible that only the MOV instruction is sufficient for this behaviour? How the MOV tells the processor to finish all previous stores?
Aucun commentaire:
Enregistrer un commentaire