Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Aug 2005 12:09:40 +0200
From:      Hans Petter Selasky <hselasky@c2i.net>
To:        Ian Dowse <iedowse@iedowse.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: How to do proper locking
Message-ID:  <200508071209.41695.hselasky@c2i.net>
In-Reply-To: <200508061702.aa50464@nowhere.iedowse.com>
References:  <200508061702.aa50464@nowhere.iedowse.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Saturday 06 August 2005 18:02, Ian Dowse wrote:
> In message <200508060139.57143.hselasky@c2i.net>, Hans Petter Selasky 
writes:
> >Yes, you are right, but the problem is, that for most callback systems in
> > the kernel, there is no mechanism that will pre-lock some custom mutex
> > before calling the callback.
> >
> >I am not speaking about adding lines to existing code, but to add one
> > extra parameter to the setup functions, where the mutex that should be
> > locked before calling the callback(s) can be specified. If it is NULL,
> > Giant will be used.
> >
> >The setup functions I have in mind are for example:  "make_dev()",
> >"bus_setup_intr()", "callout_reset()" ... and in general all callback
> > systems that look like these.
>
> Note that FreeBSD's callout subsystem does already have such a
> mechanism. Just use callout_init_mtx() and the specified mutex will
> be acquired before the callback is invoked. See callout(9) for more
> details.

Ok, thanks for the pointer. The only limitation about the "callout"'s solution 
is that it only takes one callback at a time. So the global lock has to be 
locked every time it calls a callback.

But actually, isn't it an idea that this "check some value before calling 
callback" mechanism, has some helper functions in the kernel, so that we 
don't end up with "n" different solutions ?


--HPS




>
> Iancurr_cancelled



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