This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: testandset on powerpc


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]