www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13173] New: Store reordering in core.thread / volatile fence


          Issue ID: 13173
           Summary: Store reordering in core.thread / volatile fence
           Product: D
           Version: D2
          Hardware: x86
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody puremagic.com
          Reporter: code klickverbot.at

core.thread currently uses atomicStore!(MemoryOrder.raw) as a combined volatile
store and barrier for other stores:

This only incidentally works with DMD, as atomicStore can not be inlined there.
Neither atomicStore (with any ordering) nor the proposed volatileStore can be
used to fix that code, as they only affect ordering with regard to other atomic
or volatile operations, and not the other plain assignments.

atomicFence() would work to fix the problem, but would be much too
heavy-handed, as we don't need any thread synchronization at all, just
asynchronous signal safety. We really need something like C++'s
std::atomic_signal_fence in druntime. DMD can just ignore it, if its optimizer
doesn't reorder loads/stores anyway.

Jul 20 2014