[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [microblaze-uclinux] pthread_mutex_unlock() on unlocked mutex lock system hard
Hi again,
At Fri, 27 Aug 2004 03:15:06 +0900,
yashi wrote:
>
> Hi Keith,
>
> At Wed, 25 Aug 2004 10:40:53 -0400,
> Zambrano, Keith I(GE Infrastructure) wrote:
> >
> > Hi,
> > I have been evaluating pthreads for a while, I have found that
> > using sleeps in the thread locks up the target board.
>
> even if you comment out sleep() form the prev sample kills the system
> on SUZAKU.
>
> does it work on your platform with out sleep()?
would mind to test this patch? you need to enable msrset/msrclr in
order to use this patch. I haven't find the cause of the bug, but it
worked ;p
if it works, i'll implement it without msrset/msrclr.
regards,
--
yashi
* implement testandset(); idea taken form nios version.
Index: pt-machine.h
===================================================================
RCS file: /var/cvs/uClinux-dist/uClibc/libpthread/linuxthreads/sysdeps/microblaze/pt-machine.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 pt-machine.h
--- pt-machine.h 19 Feb 2004 04:35:17 -0000 1.1.1.1
+++ pt-machine.h 26 Aug 2004 21:51:28 -0000
@@ -17,77 +17,17 @@
#endif
extern long int testandset (int *spinlock);
-extern int __compare_and_swap (long *ptr, long old, long new);
-
-/* Get some notion of the current stack. Need not be exactly the top
- of the stack, just something somewhere in the current frame. */
-#define CURRENT_STACK_FRAME __stack_pointer
-register char *__stack_pointer __asm__ ("r1");
-
-#define HAS_COMPARE_AND_SWAP
-#define IMPLEMENT_TAS_WITH_CAS
-
-/* Atomically: If *PTR == OLD, set *PTR to NEW and return true,
- otherwise do nothing and return false. */
-PT_EI int __compare_and_swap (long *ptr, long old, long new)
-{
- unsigned long psw;
-
- /* disable interrupts */
- /* This is ugly ugly ugly! */
- __asm__ __volatile__ ("
- mfs %0, rmsr;
- andi r3, %0, ~2;
- mts rmsr, r3;"
- : "=&r" (psw)
- :
- : "r3");
-
- if (likely (*ptr == old))
- {
- *ptr = new;
- __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw)); /* re-enable */
- return 1;
- }
- else
- {
- __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw)); /* re-enable */
- return 0;
- }
-}
-
-
-#ifndef IMPLEMENT_TAS_WITH_CAS
/* Spinlock implementation; required. */
PT_EI long int testandset (int *spinlock)
{
- char ret;
- unsigned psw;
+ unsigned long ret;
- /* disable interrupts */
- __asm__ __volatile__ ("
- mfs %0, rmsr;
- andi r3, %0, ~2;
- mts rmsr, r3;"
- : "=&r" (psw)
- :
- : "r3");
-
- if(*spinlock)
- {
- /* Enable ints */
- __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw));
- ret=1;
- }
- else
- {
- *spinlock=1;
- /* Enable ints */
- __asm__ __volatile__ ("mts rmsr, %0;" :: "r" (psw));
- ret=0;
- }
-
- return ret;
+ __asm__ __volatile__("msrclr r0, 0x2\n\t"
+ "lw %0, r0, %2\n\t"
+ "sw %1, r0, %2\n\t"
+ "msrset r0, 0x2\n\t"
+ : "=&r"(ret)
+ : "r"(1), "r"(spinlock)
+ : "memory");
+ return ret;
}
-
-#endif
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@itee.uq.edu.au
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/