A few questions about safe concurrent programming assumptions

John Colvin john.loughran.colvin at gmail.com
Mon Oct 7 02:55:56 PDT 2013


On Monday, 7 October 2013 at 05:26:10 UTC, Nicholas Smith wrote:
> Thanks Jonathon, these are the kinds of warnings I was looking 
> for.
>
>> There are _no_ guarantees of atomicity with shared. Yes, on 
>> some
>> architectures, writing a word size might be atomic, but the 
>> language
>> guarantees no such thing.
>
> I was looking narrowly at x86, which I *think* such a statement 
> is safe to say for. But you're absolutely right that I should 
> probably safeguard against the possibility that something could 
> go wrong there.
>
>> either that or
>> you have to mess around with core.atomic, which is the kind of 
>> code that is
>> _very_ easy to screw up, so it's generally advised not to 
>> bother with
>> core.atomic unless you actually _need_ to.
>
> It will at least ensure sequential consistency, atomic 
> load/store, and atomic operations (via atomicOp), will it not?

It will ensure whatever you tell it to. It's a set of convenience 
wrappers around some assembly instructions.


More information about the Digitalmars-d-learn mailing list