* fetch_and_add() available on PPC Linux?
@ 2001-12-06 3:56 rayson_ho
2001-12-06 4:17 ` David Edelsohn
0 siblings, 1 reply; 7+ messages in thread
From: rayson_ho @ 2001-12-06 3:56 UTC (permalink / raw)
To: linuxppc-dev
I am porting a threads library to PPC Linux... Since some applications depend on it, I can't easily switch to pthreads.
The library uses fetch_and_add(), which is available on AIX. I tried to compile it on PPC Linux, but failed to link.
I compiled the code on AIX with -S. Then I examined the assembly listing, and found that fetch_and_add() is a lib/OS call.
I would like to know if PPC Linux has something similar to fetch_and_add() on AIX, if not, are there any workarounds??
Thanks,
Rayson
----------------------------------------------
Åwªï¨Ï¥ÎHongKong.com¶l¥ó¨t²Î
Thank you for using hongkong.com Email system
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: fetch_and_add() available on PPC Linux?
2001-12-06 3:56 fetch_and_add() available on PPC Linux? rayson_ho
@ 2001-12-06 4:17 ` David Edelsohn
2001-12-06 13:07 ` Michael R. Zucca
0 siblings, 1 reply; 7+ messages in thread
From: David Edelsohn @ 2001-12-06 4:17 UTC (permalink / raw)
To: rayson_ho; +Cc: linuxppc-dev
Have you looked at the atomicity macros for PowerPC in glibc? You
want to use the load-linked store-conditional instructions. Something
along the lines of:
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
David
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: fetch_and_add() available on PPC Linux?
2001-12-06 4:17 ` David Edelsohn
@ 2001-12-06 13:07 ` Michael R. Zucca
2001-12-06 13:46 ` Holger Bettag
2001-12-06 14:07 ` fetch_and_add() available on PPC Linux?Hi, Kevin B. Hendricks
0 siblings, 2 replies; 7+ messages in thread
From: Michael R. Zucca @ 2001-12-06 13:07 UTC (permalink / raw)
To: David Edelsohn; +Cc: linuxppc-dev
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@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/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: fetch_and_add() available on PPC Linux?
2001-12-06 13:07 ` Michael R. Zucca
@ 2001-12-06 13:46 ` Holger Bettag
2001-12-06 14:07 ` fetch_and_add() available on PPC Linux?Hi, Kevin B. Hendricks
1 sibling, 0 replies; 7+ messages in thread
From: Holger Bettag @ 2001-12-06 13:46 UTC (permalink / raw)
To: linuxppc-dev
"Michael R. Zucca" <mrz5149@acm.org> writes:
[...]
> 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.
>
It is architected to be one cache block. On the 'desktop' PowerPCs (6xx, 7xx,
7xxx) that currently means 32 bytes. Some embedded models (4xx, 5xx?) have
cache blocks of 16 bytes.
Holger
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: fetch_and_add() available on PPC Linux?Hi,
2001-12-06 13:07 ` Michael R. Zucca
2001-12-06 13:46 ` Holger Bettag
@ 2001-12-06 14:07 ` Kevin B. Hendricks
2001-12-06 15:00 ` Wolfgang Denk
1 sibling, 1 reply; 7+ messages in thread
From: Kevin B. Hendricks @ 2001-12-06 14:07 UTC (permalink / raw)
To: Michael R. Zucca, David Edelsohn; +Cc: linuxppc-dev
Hi,
> See the PPC manual for the lock granule size. I forget what it is off
> the top of my head.
I think it is the same as the cache line size (32 bytes for most ppc
machines but defintely that cache line size changes for some
implementations (so go with at least 32 bytes and you should be safe).
Kevin
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: fetch_and_add() available on PPC Linux?Hi,
2001-12-06 14:07 ` fetch_and_add() available on PPC Linux?Hi, Kevin B. Hendricks
@ 2001-12-06 15:00 ` Wolfgang Denk
2001-12-06 21:51 ` Kevin B. Hendricks
0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Denk @ 2001-12-06 15:00 UTC (permalink / raw)
To: Kevin B. Hendricks; +Cc: Michael R. Zucca, David Edelsohn, linuxppc-dev
In message <20011206140445.TQHJ17034.tomts10-srv.bellnexxia.net@there> you wrote:
>
> I think it is the same as the cache line size (32 bytes for most ppc
> machines but defintely that cache line size changes for some
> implementations (so go with at least 32 bytes and you should be safe).
...except on embedded CPUs like MPC8xx which have a cache line size
of only 16 bytes
Wolfgang Denk
--
Software Engineering: Embedded and Realtime Systems, Embedded Linux
Phone: (+49)-8142-4596-87 Fax: (+49)-8142-4596-88 Email: wd@denx.de
"I've finally learned what `upward compatible' means. It means we get
to keep all our old mistakes." - Dennie van Tassel
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: fetch_and_add() available on PPC Linux?Hi,
2001-12-06 15:00 ` Wolfgang Denk
@ 2001-12-06 21:51 ` Kevin B. Hendricks
0 siblings, 0 replies; 7+ messages in thread
From: Kevin B. Hendricks @ 2001-12-06 21:51 UTC (permalink / raw)
To: Wolfgang Denk, Kevin B. Hendricks
Cc: Michael R. Zucca, David Edelsohn, linuxppc-dev
Hi,
On December 6, 2001 10:00, Wolfgang Denk wrote:
> In message <20011206140445.TQHJ17034.tomts10-srv.bellnexxia.net@there>
you wrote:
> > I think it is the same as the cache line size (32 bytes for most ppc
> > machines but defintely that cache line size changes for some
> > implementations (so go with at least 32 bytes and you should be safe).
>
> ...except on embedded CPUs like MPC8xx which have a cache line size
> of only 16 bytes
So 32 bytes apart is fine. That will make it two cache line sizes on your
machine so that more than meets the min lock granularity.
Kevin
** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2001-12-06 21:51 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-12-06 3:56 fetch_and_add() available on PPC Linux? rayson_ho
2001-12-06 4:17 ` David Edelsohn
2001-12-06 13:07 ` Michael R. Zucca
2001-12-06 13:46 ` Holger Bettag
2001-12-06 14:07 ` fetch_and_add() available on PPC Linux?Hi, Kevin B. Hendricks
2001-12-06 15:00 ` Wolfgang Denk
2001-12-06 21:51 ` Kevin B. Hendricks
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).