This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: testandset on powerpc
- To: Andreas Jaeger <aj at suse dot de>
- Subject: Re: testandset on powerpc
- From: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Date: Tue, 18 Jul 2000 18:19:58 +0200
- Cc: Geoff Keating <geoffk at cygnus dot com>,libc-alpha at sourceware dot cygnus dot com
- References: <Geoff Keating's message of "Tue, 18 Jul 2000 08:52:27 -0700"><ho66q3vbfb.fsf@maclaurin.suse.de><200007181528.IAA12286@localhost.cygnus.com><hok8ejtpgy.fsf@maclaurin.suse.de><200007181552.IAA12307@localhost.cygnus.com>
At 18:02 18.07.00, Andreas Jaeger wrote:
> >>>>> Geoff Keating writes:
>
> >> Cc: libc-hacker@sourceware.cygnus.com
> >> From: Andreas Jaeger <aj@suse.de>
> >> Date: 18 Jul 2000 17:42:05 +0200
>
>Geoff> It'd be better if the generic code could be written to simply use
>Geoff> compare_and_swap if it is available. That would make porting easier.
> >>
> >> Why? All platforms - except ppc - have testandset. IMHO porting
> >> would be easier if ppc had testandset ;-).
>
>Geoff> I don't understand. testandset is a specialisation of
>Geoff> compare_and_swap. Every platform which can do compare_and_swap can do
>Geoff> testandset. It's just that the generic code doesn't know this.
>
>Geoff> It shouldn't be necessary for each porter to have to work out how to
>Geoff> make compare_and_swap do testandset. It should just happen.
>
>Since testandset is a specialisation it can be optimized - and that
>seems to be the reason why testandset is used here instead of
>compare_and_swap.
>
>So what's the right thing to do?
>
>- Add some define like HAS_TESTANDSET and implement testandset with
> compare_and_swap if testandset is not available?
I have done a patch which defines IMPLEMENT_TAS_AS_CAS in
powerpc/pt-machine.h and define testandset(p) to !__compare_and_swap(p,0,1)
in spinlock.h then. I haven't sent it yet, because I had strange problems
with rpcgen (maybe related to string handling?) yesterday and so I couldn't
test it yet.
>- Remove testandset completly?
Probably testandset can be implemented with less assembler instructions on
some machines, even on PPC it saves one instruction.
Franz.