MIPS deadlock bug fix

Slegers, Walter Walter.Slegers at nl2.vdogrp.de
Thu Jan 11 01:54:29 PST 2001


Hi Godmar,

> Are you saying that there's no access to any atomic instruction
> (test-and-set, cmp-exchange, fetch-and-add, whatever) in usermode
> on the MIPS R3000?

It's sad but true.

> Well, then why don't you put the generic version with jthread_ in 
> your config/mips/... file and ifdef it with (R3000) or whatever macro
> the compiler defines when compiling for it.  I take it the R4000 fixes
> that oversight.

Done. My locks.c file is now back to the original version.
I've modified config/mips/common.h to contain:

	#ifndef __mips_common_h
	#define __mips_common_h

	#ifdef __R3000__

	/* only works when Kaffe is compiled with jthreads */

	#define	COMPARE_AND_EXCHANGE(A,O,N) 		\
	({						\
		int val = 0;				\
							\
		jthread_suspendall();			\
		if (*A == O)				\
		{					\
			*A = N;				\
			val = 1;			\
		}					\
		jthread_unsuspendall();			\
		val;					\
	})

	#else

	#define COMPARE_AND_EXCHANGE(A,O,N)		\
	({						\
		unsigned int tmp, ret;			\
	 						\
		asm volatile(				\
		"	.set	noreorder\n"		\
		"	.set	mips2\n"		\
		"	li	%1, 0\n"		\
		"1:	ll	%0, %3\n"		\
		"	bne	%0, %4, 2f\n"		\
		"	move	%0, %5\n"		\
		"	sc	%0, %2\n"		\
		"	beqz	%0, 1b\n"		\
		"	nop\n"				\
		"	li	%1, 1\n"		\
		"2:	.set	mips0\n"		\
		"	.set	reorder\n"		\
		: "=&r" (tmp), "=r" (ret), "=m" (*(A))	\
		: "m" (*(A)), "r" (O), "r" (N)		\
		: "memory");				\
		ret;					\
	})

	#endif

The non R3000 part is from Edouard. I can only say that it compiles and
I think it works. Edouard can you test it and let us know?
For my R3000 it compiles, and runs repeatedly without problems.

Kind regards,
    Walter



-----------------------------------------------------------
This Mail has been checked for Viruses
Attention: Encrypted Mails can NOT be checked !

***

Diese Mail wurde auf Viren ueberprueft
Hinweis: Verschluesselte Mails koennen NICHT geprueft werden!
------------------------------------------------------------


More information about the kaffe mailing list