[Interest] QMap and thread-safe.

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Fri Jul 26 09:36:11 CEST 2013


On Fri, Jul 26, 2013 at 12:30 PM, Thiago Macieira <thiago.macieira at intel.com
> wrote:

> On sexta-feira, 26 de julho de 2013 10:27:28, Mandeep Sandhu wrote:
> > > Doing both at the same time is not atomic anywhere unless you use
> > > specialised
> > > fetch-and-add instructions, which the compiler never generates for you.
> >
> > By both here, you mean fetch AND add, right?
>
> Right
>
> > And in x86 such a operation
> > (add) on a machine word is atomic w/o using special instructions?
>
> ADD is atomic, but usually an atomic increment is done with LOCK ADD, to
> ensure that no other processor is trying to access the same memory
> location.
> The compiler will never generate a LOCK.
>
> In other words, ADD is atomic for single-CPU operations. As soon as there's
> more than one CPU, it isn't enough.
>

Got it. Thanks for clearing this up!

-mandeep
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130726/d87b2c5f/attachment.html>


More information about the Interest mailing list