DIP 1024--Shared Atomics--Community Review Round 1
Walter Bright
newshound2 at digitalmars.com
Tue Oct 1 20:34:27 UTC 2019
On 10/1/2019 7:14 AM, IGotD- wrote:
> On Tuesday, 1 October 2019 at 10:40:52 UTC, Mike Parker wrote:
>> "This change will require using core.atomic or equivalent functions to read
>> and >write to shared memory objects. It will prevent unintended, inadvertent
>> non-use of >atomic access."
>
> What if the type is complex (like a struct) outside what the ISA can handle?
> Usually this only applies for integers 8 - 128 bits depending on architecture,
> anything beyond that is out of reach unless you want to dig into Intel TSX which
> the shared attribute isn't suitable for.
>
> Another thing that is left out are the effects of operator overloading.
>
> shared int s;
>
> // What would this do? Atomically increment s or just atomically load s, add one
> // and then atomically store s?
> s = s + 1;
> // Would this atomically increase s and return the value after increment?
> s++;
Actually, shared operations would no longer be generated from the syntax. They'd
all be done with library functions, which could be implemented as intrinsics by
the compiler.
If it's outside what the ISA could handle, then those library functions would
not be intrinsics, and it's up to the implementation of those functions to make
it work.
More information about the Digitalmars-d
mailing list