[Mono-dev] _wapi_sparc_lock

David S. Miller davem at davemloft.net
Tue Mar 28 06:12:32 EST 2006


From: "Zoltan Varga" <vargaz at gmail.com>
Date: Tue, 28 Mar 2006 12:46:09 +0200

>   One thing I'm worried about with this change is that is falls back to the
> pthread_ set of functions when using a compiler other than GCC. This is most
> likely not a problem on sparc/linux, but can be a problem on sparc/solaris.
> The pthread_ functions are slower, and even less async safe than the existing
> spin functionality. So I think it would be better to keep the spin stuff.

The pthread stuff is more async safe by a mile.  Just because it
prints out a loud warning doesn't mean it's worse than the current
sparc spinlock stuff :-)

At least with the pthread stuff, there is a cleanup registered that
will run and release the pthread mutex most of the time if the thread
exits.

With the spinlocks, the lock is just left held and we lock up in the
other threads, even if the thread exits cleanly, whilst that thread
holds the lock.

That's exactly the bug that started me messing with this stuff at
all. :-) You can't use spinlocks for this stuff, period.  It has the
"partial state update" problem, making it deadlock prone.  For these
reasons you can't invoke the spinlock based atomic operations safely
inside of exception handlers or signal handlers, example:

	start atomic, take spinlock
	SIGNAL
		start atomic, take spinlock --> HANG

With the old spinlock code, mono hangs not even 30 seconds into
running the test suite on my 32 processor nigara box.  I consider that
not working.

I would suggest putting this patch in, and waiting for a person
knowledgable with the Sun compiler inline assembler syntax to code up
equivalent code to mine for that case.



More information about the Mono-devel-list mailing list