Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 27 Sep 2000 12:09:01 -0700 (PDT)
From:      John Polstra <jdp@polstra.com>
To:        arch@freebsd.org
Cc:        eischen@vigrid.com
Subject:   Re: Mutexes and semaphores
Message-ID:  <200009271909.MAA07294@vashon.polstra.com>
In-Reply-To: <Pine.SUN.3.91.1000926065812.26612A-100000@pcnet1.pcnet.com>
References:  <Pine.SUN.3.91.1000926065812.26612A-100000@pcnet1.pcnet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In article
<Pine.SUN.3.91.1000926065812.26612A-100000@pcnet1.pcnet.com>, Daniel
Eischen <eischen@vigrid.com> wrote:

> If you absolutley need recursive mutexes, then roll your own and
> keep the base mutex simple.  This is trivial to do and makes the
> base mutex more efficient without the need to check for recursive
> ownership.

I think it would make sense to make recursive mutexes a separate
type, so they don't complicate the non-recursive ones.  But the "roll
your own" idea would work against eventually getting rid of recursive
mutexes entirely.  If they are implemented ad hoc in various places,
it will be hard to find them all later.  Better to have a standard
implementation that's easy to search for.

> Mutexes should be held for very short amounts of time, and it should
> be apparent in the encompassing code where the mutex is taken and
> where it is released.  In your example, what do you do in the case
> of abnormal exits from recursively called code?  It makes it far
> more easier to handle this situation if you roll your own mutex
> and keep track of the ref count and owner yourself.  If you don't,
> you'll end up adding mtx_exit_and_clear_refcount().

Yes, that's a good point.

> My main concern is not to eliminate recursive mutexes, though I
> still think they should go.  I would like to see all barriers to
> eliminating the flags/options to mtx_enter() and mtx_exit() removed.
> The current form of the mutex routines is not an API/ABI we should
> be using.

I'm not too thrilled with the API myself.

John
-- 
  John Polstra                                               jdp@polstra.com
  John D. Polstra & Co., Inc.                        Seattle, Washington USA
  "Disappointment is a good sign of basic intelligence."  -- Chögyam Trungpa



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?200009271909.MAA07294>