[phobos] Fwd: Re: Ruling out arbitrary cost copy construction?

David Simcha dsimcha at gmail.com
Mon Nov 1 12:53:51 PDT 2010


I can't remember the reference off the top of my head, but I think inc [EAX]
w/o the lock prefix is atomic for weak definitions of atomic, i.e. it has no
intermediate states.  However, without the lock prefix it is not
sequentially consistent.

On Mon, Nov 1, 2010 at 2:47 PM, Robert Jacques <sandford at jhu.edu> wrote:

> On Mon, 01 Nov 2010 14:32:39 -0400, Andrei Alexandrescu <andrei at erdani.com>
> wrote:
>
>> Increment is not atomic on most processors, including x86 (inc
>> [someAddress] does not exist).
>>
>> Andrei
>>
>
> Umm, inc [address] does exits. However, in order to make it atomic, you're
> supposed to use the lock prefix. I.e.
>
> ref int atomic_inc(ref int value) {
>    asm {
>        lock;                           // Makes this instruction atomic.
>        inc [EAX];                       // implicit pointer type
>        //inc int ptr [EAX]; // explicit pointer type
>
>    }
> }
>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20101101/57df72a5/attachment.html>


More information about the phobos mailing list