From: kaz K. <kk...@rr...> - 2001-04-09 02:54:15
|
Hi, Lewis Girod <mim...@ya...> wrote: > Mitch Davis <md...@po...> wrote: >> Could you post the source for a tiny program which >> demonstrates the mutex problem? > > Yes.. the following program demonstrates the problem, > although it works fine on an x86 system. It would be > helpful to know if other people see this problem; it > might very well be something wrong with our > development environment.. I've just found a few reverse tests in our spinlock implementation in GNU libc/linuxthreads. Your test program behaves same as in x86 with applying the attached patch to glibc. Can you please test this patch? The last part of the diff to pt-machine.h is irrelevant to this problem and very experimental. So you can delete it. Thank you for your test program and sorry for my bad response. kaz -- Index: pspinlock.c =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/sysdeps/sh/pspinlock.c,v retrieving revision 1.2 diff -u -r1.2 pspinlock.c --- pspinlock.c 2000/12/27 17:17:16 1.2 +++ pspinlock.c 2001/04/09 02:24:11 @@ -31,7 +31,7 @@ : "=r" (val) : "r" (lock) : "memory"); - while (val != 0); + while (val == 0); return 0; } @@ -47,7 +47,7 @@ : "=r" (val) : "r" (lock) : "memory"); - return val ? EBUSY : 0; + return val ? 0 : EBUSY; } weak_alias (__pthread_spin_trylock, pthread_spin_trylock) Index: pt-machine.h =================================================================== RCS file: /cvs/glibc/libc/linuxthreads/sysdeps/sh/pt-machine.h,v retrieving revision 1.3 diff -u -r1.3 pt-machine.h --- pt-machine.h 2000/12/18 05:55:14 1.3 +++ pt-machine.h 2001/04/09 02:24:12 @@ -32,11 +32,11 @@ __asm__ __volatile__( "tas.b @%1\n\t" "movt %0" - : "=z" (ret) + : "=r" (ret) : "r" (spinlock) : "memory", "cc"); - return ret; + return (ret == 0); } @@ -44,3 +44,13 @@ of the stack, just something somewhere in the current frame. */ #define CURRENT_STACK_FRAME stack_pointer register char * stack_pointer __asm__ ("r15"); + +/* Return the thread descriptor for the current thread. */ +struct _pthread_descr_struct; +#define THREAD_SELF \ + ({ struct _pthread_descr_struct *self; \ + __asm__("stc gbr,%0" : "=r" (self)); self;}) + +/* Initialize the thread-unique value. */ +#define INIT_THREAD_SELF(descr, nr) \ + ({ __asm__("ldc %0,gbr" : : "r" (descr));}) |