No memory model

deadalnix deadalnix at gmail.com
Tue Oct 22 10:53:56 PDT 2013


On Tuesday, 22 October 2013 at 09:07:38 UTC, qznc wrote:
> On Tuesday, 22 October 2013 at 00:26:48 UTC, deadalnix wrote:
>> On Monday, 21 October 2013 at 20:50:28 UTC, qznc wrote:
>>> As far as I google, D has not specified a memory model.
>>>
>>> However, I assume it should basically be the same as the C++ 
>>> memory model: Sequential consistency for data-race-free 
>>> programs.
>>
>> shared = sequential consistency.
>> immutable = immutable.
>> TL = do whatever you want to make my program faster.
>
> So Ds shared has a similar effect as Javas volatile. The 
> difference is transitivity like with const.
>

Yes.

> Nevertheless, core.atomic also plays into this. Why do we need 
> atomicStore, if we have shared? Why does atomicStore require 
> its argument to be shared?

Several reasons.
  - Interoperability with C/C++, that do not understand shared.
  - Relaxed atomics.
  - DMD do not emit correct codegen for shared.


More information about the Digitalmars-d mailing list