fetch_and_add() available on PPC Linux?

Michael R. Zucca mrz5149 at acm.org
Fri Dec 7 00:07:41 EST 2001


At 11:17 PM -0500 12/5/01, David Edelsohn wrote:

>0:
>    lwarx   %1,0,%4         # oval = (*ptr) [linked]
>    add%I3  %2,%1,%3        # tmp = oval + val
>    stwcx.  %2,0,%4         # (*ptr) = tmp  [conditional]
>    bne-    0b              # if (store failed) retry

The only caveat is that the ptr to any two of these items must be in
individual lock granules. If the software has an array of locks that are
just a bunch of long-words, there's going to be difficultly. However, given
that this was an AIX box, and was probably a POWER machine, it's likely
that the POWER machine has the same lock granule restriction.

See the PPC manual for the lock granule size. I forget what it is off the
top of my head.

____________________________________________________________________
 Michael Zucca - mrz5149 at acm.org
 "I will choose a path that's clear. I will choose Freewill. "
  --Rush, Freewill
____________________________________________________________________


** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/





More information about the Linuxppc-dev mailing list