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

David Simcha dsimcha at gmail.com
Tue Nov 2 07:28:28 PDT 2010


Yea, I tried it out, and I stand corrected.

On Tue, Nov 2, 2010 at 10:20 AM, Sean Kelly <sean at invisibleduck.org> wrote:

> On Nov 1, 2010, at 10:49 AM, David Simcha wrote:
>
> >
> >
> > On Mon, Nov 1, 2010 at 1:39 PM, Michel Fortin <michel.fortin at michelf.com>
> 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.
>
> The second form is only atomic when preceded by a LOCK modifier.  It's
> still done in the CPU as a RMW operation.
>
> _______________________________________________
> 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/20101102/b2af2ed0/attachment.html>


More information about the phobos mailing list