From owner-freebsd-hackers@FreeBSD.ORG Sun Aug 7 10:08:45 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B783D16A41F for ; Sun, 7 Aug 2005 10:08:45 +0000 (GMT) (envelope-from hselasky@c2i.net) Received: from swip.net (mailfe01.swip.net [212.247.154.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id 38B584423A for ; Sun, 7 Aug 2005 10:08:45 +0000 (GMT) (envelope-from hselasky@c2i.net) X-T2-Posting-ID: gvlK0tOCzrqh9CPROFOFPw== Received: from mp-217-199-237.daxnet.no ([193.217.199.237] verified) by mailfe01.swip.net (CommuniGate Pro SMTP 4.3.4) with ESMTP id 43307752; Sun, 07 Aug 2005 12:08:42 +0200 From: Hans Petter Selasky To: Ian Dowse Date: Sun, 7 Aug 2005 12:09:40 +0200 User-Agent: KMail/1.7 References: <200508061702.aa50464@nowhere.iedowse.com> In-Reply-To: <200508061702.aa50464@nowhere.iedowse.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200508071209.41695.hselasky@c2i.net> Cc: freebsd-hackers@freebsd.org Subject: Re: How to do proper locking X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: hselasky@c2i.net List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 07 Aug 2005 10:08:45 -0000 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