synchronized vs. C volatile
SK
sk at metrokings.com
Mon Aug 9 08:13:57 PDT 2010
On Mon, Aug 9, 2010 at 7:29 AM, BCS <none at anon.com> wrote:
> Hello SK,
>
>> Does 'synchronized' mean the exact same thing as the C 'volatile'
>> qualifier when applied to basic types?
>> As in:
>> synchronized int x;
>
> I'm reasonably sure that it doesn't. I think synchronized invokes a mutex
> for access and C's volatile just suppresses some optimizations.
>
> --
> ... <IXOYE><
>
Andrei's book does not list volatile as a keyword in D. I'm at a loss
unless 'synchronized' performs double duty as volatile. For example,
device status registers are "const volatile" in C/C++. The compiler
disallows writes and does not optimize away reads. Mutexes are
irrelevant and for that matter the processor may not (and need not)
even support atomic instructions.
-steve
More information about the Digitalmars-d
mailing list