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 <[email protected]> wrote: > On Mon, 01 Nov 2010 14:32:39 -0400, Andrei Alexandrescu <[email protected]> > 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 > [email protected] > http://lists.puremagic.com/mailman/listinfo/phobos >
_______________________________________________ phobos mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/phobos
