Em Domingo 04 Outubro 2009, às 10:28:46, você escreveu: > Le 4 oct. 09 à 09:35, Thiago Macieira a écrit : > > Em Sábado 3. Outubro 2009, às 17.13.48, você escreveu: > >> Can I use QAtomicInt as "an Int with basic operations being atomic": > >> like getting, setting its value. Returning it from a function. > >> If not, when and how can I use it. > > > > int is already atomic in those operations. > > > > QAtomicInt introduces new atomic operations: fetch-and-add, test-and- > > set and > > fetch-and-set. As for the memory ordering semantics, you had better > > read a > > book. > > But native set and get operations do not ensure cache consistency > among your processors (you are just guaranteed that, as long as your > data are correctly aligned, you'll never read a partial result from > another thread) while atomic fetch-and-add, test-and-set and fetch-and- > set use a memory barrier (AFAIK, atomic integers are useless without > memory barrier).
Hmm... you're asking for loadAcquire and storeRelease functions to be added.
I thought of adding that before, but I didn't. The only platform where I
thought it would be necessary -- the Itanium -- already does it if the
variable is volatile.
The code:
volatile int i;
i = 1;
Produces assembly:
mov r15 = 1
add r2 = @gprel(i), gp
;;
st4.rel [r2] = r15
--
Thiago Macieira - thiago.macieira (AT) nokia.com
Senior Product Manager - Nokia, Qt Development Frameworks
Sandakerveien 116, NO-0402 Oslo, Norway
Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14 San Francisco, California: Nov 2 - 4
http://qt.nokia.com/qtdevdays2009
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Qt4-preview-feedback mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback
