[cpp-threads] Brief example ITANIUM Implementation forC/C++MemoryModel
Peter Dimov
pdimov at mmltd.net
Fri Jan 2 20:28:08 GMT 2009
Alexander Terekhov:
> Now, what is your reasoning regarding
>
> P1: Y.store(1, relaxed);
> P2: Z.store(1, relaxed); fence(seq_cst); a = Y.load(relaxed);
> P3: b = Y.load(relaxed); fence(seq_cst); c = Z.load(relaxed);
>
> and a=0, b=1, c=0 outcome?
Allowed, I think. If you make P1's store seq_cst, it would be disallowed.
seq_cst only works with seq_cst (I was initially surprised by that too). The
rationale - or my understanding of it - is that seq_cst is optimized to be
as efficient as possible under the assumption that the program only uses
seq_cst or ordinary operations. Under these constraints, the loads can be
plain MOV on x86, thereby not killing performance too much. :-)
More information about the cpp-threads
mailing list