Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Sep 2000 11:18:42 +0930
From:      Greg Lehey <grog@lemis.com>
To:        Alfred Perlstein <bright@wintelcom.net>
Cc:        arch@FreeBSD.ORG
Subject:   Re: Interruptable mutex aquires.
Message-ID:  <20000912111842.F88615@wantadilla.lemis.com>
In-Reply-To: <20000910193602.B12231@fw.wintelcom.net>; from bright@wintelcom.net on Sun, Sep 10, 2000 at 07:36:02PM -0700
References:  <20000910193602.B12231@fw.wintelcom.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sunday, 10 September 2000 at 19:36:02 -0700, Alfred Perlstein wrote:
>
> There's a lot of code in the kernel that does this:
>
> while(lock != mine) {
> 	error = tsleep(&lock, PRIBIO, "foo", PCATCH);
> 	if (error)
> 		return(error);
> }
> lock = mine;
>
> Ok, well the equivelant way to do this with mutexes would be
> to add a new function 'mtx_enter_interruptable()' [*]
> that attempts to aquire a mutex but if interrupted returns
> an error suitable for aborting the operation.
>
> Nice, easy, simple and fits well as a replacement tool for
> the current while(lock != mine) mechnism.
>
> Some people have discussed making a new flag 'MTX_CATCH', personally
> that sounds terrible, I'm already not really thrilled with the
> 'do-all' functions that have been put into place as our primatives,
> as they are not very intuative, it's hard to tell at a glance
> exactly what is a spinlock and what is a task switching mutex, let's
> _please_ try to keep this readable and stick away from the flags.

I suppose there's a case for simpler terminology, but have you looked
at the mutex code?  There's a *lot* of code in there, and apart from
the duplication, maintenance would be terrible.  I'd suggest the flag
approach, but there's nothing stopping a macro encapsulation with a
name like mtx_enter_interruptable.

> At the BSDi/FreeBSD SMP meeting I remeber asking Chuck why he
> implemented it this way, his respnonse was something along the lines
> of "it seemed like a good idea to have an object that one could spin
> or sleep on depending on the locatation or state of the object
> encapsulating the mutex, but in practice we've never used nor needed
> to use a mutex as a spinlock or a spinlock as a mutex"

Ugh.  Another use of the word "mutex".  I thought we were using mutex
to cover both terms.

Don't forget that BSD/OS 5 hasn't been released yet.  Rather
amusingly, ours is available before theirs :-) But it's quite possible
that they will find a use for this kind of mutex.

> [*] yes, today's C compilers actually support identifiers longer
> than 6 characters!  if mtx_enter_interruptable is too offensive
> I could live with mtx_enter_intr().

This isn't a question of identifier length, it's a question of
style(9).  As long as we have 8 character indentation and only 80
characters text width, we're damned to using short identifiers.

Greg
--
Finger grog@lemis.com for PGP public key
See complete headers for address and phone numbers


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000912111842.F88615>