[dmd-concurrency] draft 7
Fawzi Mohamed
fawzi at gmx.ch
Tue Feb 2 04:20:16 PST 2010
On 2-feb-10, at 07:19, Robert Jacques wrote:
> On Tue, 02 Feb 2010 01:04:37 -0500, Sean Kelly
> <sean at invisibleduck.org> wrote:
>>> A problem that can come up is that the variable is promoted to a
>>> register in a loop and is not updated from the memory.
>>> To avoid this one can use volatile. This issue is a priory
>>> disconnected with the presence of barriers (well one would hope
>>> that a correct compiler disables "upgrading to registers" for
>>> variables in a locked section crossing the boundary of it, but a
>>> priory it doesn't have to be like that, and especially using just
>>> memory barriers, I would not trust current compilers to always do
>>> the correct thing without a "volatile".
>>
>> Sadly, volatile is deprecated in D 2.0. You pretty much have to
>> use inline asm and rely on the fact that Walter has said D
>> compilers should never optimize in or across asm code.
>
> Well, to the best of my knowledge volatile has never been
> implemented in D 1.0, which is one of the reason's it was dropped
> from D 2.0.
that is very sad, I did find volatile very useful, I was interpreting
it as something like a way to switch off the optimizations in a code
segment, so that one can have some kind of portable asm.
I find it very useful together with barriers...
More information about the dmd-concurrency
mailing list