synchronized vs. C volatile

SK sk at metrokings.com
Mon Aug 9 17:09:54 PDT 2010


On Mon, Aug 9, 2010 at 9:55 AM, Lutger <lutger.blijdestijn at gmail.com> wrote:
>
> I'm not an expert on this, but if I am not mistaken the shared type qualifier
> will handle the barriers, require atomic ops and prevent reordering compiler
> optimizations so it looks like this one will take care of what volatile used to
> do, right?
>
>

Right, shared sounds better.  However, atomics must not sneak in:
* Many processors do not support atomics
Even with processor support,
* Many device interconnects do not support atomic transactions
Even with interconnect support,
* Many devices do not support atomic transactions and will just
generate a bus error

So long as code does not attempt a read-modify-write operation, shared
has the opportunity to do the right thing, namely implement volatile
semantics.  Cases with volatile read-modify-write would have to be
split -- awkward, but maybe ok?

asm() hacks to fake volatile are too embarrassing to consider in a
promising new systems language!

-steve


More information about the Digitalmars-d mailing list