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.<br>
<br><div class="gmail_quote">On Mon, Nov 1, 2010 at 2:47 PM, Robert Jacques <span dir="ltr"><<a href="mailto:sandford@jhu.edu">sandford@jhu.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Mon, 01 Nov 2010 14:32:39 -0400, Andrei Alexandrescu <<a href="mailto:andrei@erdani.com" target="_blank">andrei@erdani.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Increment is not atomic on most processors, including x86 (inc [someAddress] does not exist).<br>
<br>
Andrei<br>
</blockquote>
<br></div>
Umm, inc [address] does exits. However, in order to make it atomic, you're supposed to use the lock prefix. I.e.<br>
<br>
ref int atomic_inc(ref int value) {<br>
asm {<br>
lock; // Makes this instruction atomic.<br>
inc [EAX]; // implicit pointer type<br>
//inc int ptr [EAX]; // explicit pointer type<div><div></div><div class="h5"><br>
}<br>
}<br>
<br>
<br>
_______________________________________________<br>
phobos mailing list<br>
<a href="mailto:phobos@puremagic.com" target="_blank">phobos@puremagic.com</a><br>
<a href="http://lists.puremagic.com/mailman/listinfo/phobos" target="_blank">http://lists.puremagic.com/mailman/listinfo/phobos</a><br>
</div></div></blockquote></div><br>