A breach of immutability due to memory implicit conversions to immutable without synchronisation, maybe??

Neia Neutuladh neia at ikeran.org
Mon Nov 12 00:31:01 UTC 2018


On Sun, 11 Nov 2018 15:48:31 -0500, Steven Schveighoffer wrote:
> Wait, wouldn't the atomicStore create a barrier, such that all the code
> before it must execute?

It creates a smaller barrier that's supposed to be good enough (`LOCK 
XCHG` instead of `MFENCE`). And it *is* good enough when dealing with 
value types. I'm not good with multithreading, so I'm not entirely certain 
whether this is an actual problem in druntime.

`LOCK XCHG` will serialize access for the global variable and any cache 
line containing it. It will also limit reordering. I haven't found 
anything remotely definitive on whether it provides a strong enough barrier 
for reordering and memory operations to suffice here, but I'd put a small 
bet in favor of it.


More information about the Digitalmars-d mailing list