tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: mutexes, locks and so on...



On 2010-11-19 01:16, Andrew Doran wrote:
On Wed, Nov 17, 2010 at 03:03:20PM +1100, matthew green wrote:

- hppa seems to have a mutex implemented without cas.  is it broken?

FWIW, the sparc implementation is only broken on SMP.

My recollection is that there were problems with the assembly that we
were using, we didn't get to the bottom of it.  On top of that I think
there is a race condition with the interlock trick that we were going to
use for sparc but I can't remember what it was.  Possibly related to
preemption or interrupts (i.e. mutex_enter inteerupted with the interlock
part held but mutex owner not set). If it comes to me I'll post back.

The mutex code is (sadly) not very well documented though. I thought it was, initially, but I have had to find out through looking through code, and testing, to find out how I really need to write the code to (hopefully) work.

Also, the API is somewhat confusing, and I almost dare to say, bad. We have functions that supposedly work on mutexes, that actually don't even take a mutex as an argument, and functions that are expected to return values, for which there is absolutely no documentation. And we actually seem to have two different indicators if we have taken a mutex or not, and which is used seems to depend, and if they get out of sync, even for a moment, it can cause a system lockup.

Surprising, in a way. I would have expected mutexes to be very straight forward, and yet we seem to have a very convoluted and complex implementation. I can partly dodge it, but not enough by a longshot.

And looking at the only other port that have it's own implementation of mutexes, I'm surprised it even works. I can't really understand why, and would be happy to try and figure it if I missed something, or if the hppa code actually can lock up a system as well, if you are unlucky (chances on an unloaded system is rather low, but I think it can happen).
Anyone using the hppa port *heavily* around here?

        Johnny

--
Johnny Billquist                  || "I'm on a bus
                                  ||  on a psychedelic trip
email: bqt%softjar.se@localhost             ||  Reading murder books
pdp is alive!                     ||  tryin' to stay hip" - B. Idol


Home | Main Index | Thread Index | Old Index