atomic Weapons: The C++ Memory Model and Modern Hardware

Marco Leise Marco.Leise at gmx.de
Mon Jul 8 17:05:09 PDT 2013


Am Mon, 08 Jul 2013 21:04:01 +0200
schrieb "Flamaros" <flamaros.xavier at gmail.com>:

> http://herbsutter.com/2013/02/11/atomic-weapons-the-c-memory-model-and-modern-hardware/
> 
> Is D and DMD aware of those kind of issues with atomic?

I haven't looked into the talk, but I can say this: D offers
atomic operations like loads, stores, fences and CAS. They are
the lowest level you can go and the responsibility to be
informed about the caveats lies with you as the programmer. I
recently wrote a mostly lock free circular buffer and on the D
IRC channel there were a few helpful people who made me aware
of how multi-core CPUs and caches work. Fortunately on x86
architectures at least, atomic operations are pretty sane and
fast.

Other threading options in D are classical mutexes and
conditions or thread communication through message passing,
which is at the highest level and really hard to mess up. :)

-- 
Marco



More information about the Digitalmars-d mailing list