[dmd-concurrency] shared arrays
Andrei Alexandrescu
andrei at erdani.com
Fri Jan 15 22:57:18 PST 2010
Well no problem. Atomic assign can be trivially implemented with CAS:
shared long assignThis;
shared long toThis;
shared long dummy;
do dummy = toThis; while (!cas(&toThis, dummy, assignThis));
Andrei
Sean Kelly wrote:
> The two options for a LOCK assign on x86 are CAS and XCHG. And unfortunately, the only one available for more than the bus width is CAS.
>
> On Jan 15, 2010, at 10:18 AM, Andrei Alexandrescu wrote:
>
>> I was asking mostly about 64-bit atomic assigns (not CAS), i.e. long assignments. I take it we can't assume they are atomic?
>>
>> Andrei
>>
>> Sean Kelly wrote:
>>> On Jan 15, 2010, at 5:44 AM, Robert Jacques wrote:
>>>> From wikipedia:
>>>> "Early AMD64 processors lacked the CMPXCHG16B instruction, which is an extension of the CMPXCHG8B instruction present on most post-486 processors. Similar to CMPXCHG8B, CMPXCHG16B allows for atomic operations on 128-bit double quadword (or oword) data types. This is useful for parallel algorithms that use compare and swap on data larger than the size of a pointer, common in lock-free and wait-free algorithms. Without CMPXCHG16B one must use workarounds, such as a critical section or alternative lock-free approaches"
>>> Oops, you're right. The problem was cx16, not cx8. Either way, dwcas isn't reliably available anywhere but x86.
>>> _______________________________________________
>>> dmd-concurrency mailing list
>>> dmd-concurrency at puremagic.com
>>> http://lists.puremagic.com/mailman/listinfo/dmd-concurrency
>> _______________________________________________
>> dmd-concurrency mailing list
>> dmd-concurrency at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/dmd-concurrency
>
> _______________________________________________
> dmd-concurrency mailing list
> dmd-concurrency at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-concurrency
More information about the dmd-concurrency
mailing list