On Mon, Nov 1, 2010 at 1:39 PM, Michel Fortin <[email protected]>wrote:
> > Is "i++" really atomic when i is a size_t? I though it was a > read-modify-write operation. The read might be atomic, the write might be > atomic, but the whole isn't. And in addition to atomicity, it needs to be > sequentially consistent unless we change the GC to keep threads frozen while > calling the destructors. > > In theory it could be read-modify-write because you never know if some incredibly stupid compiler will do something like: mov EAX, [someAddress]; inc EAX; mov [someAddress], EAX; instead of just: inc [someAddress]; However, I'm pretty sure the second form is atomic, and even if it's not formally guaranteed, any reasonable compiler would use the single inc instruction form.
_______________________________________________ phobos mailing list [email protected] http://lists.puremagic.com/mailman/listinfo/phobos
