From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 6 16:02:20 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 1EB9016A41F for ; Sat, 6 Aug 2005 16:02:20 +0000 (GMT) (envelope-from iedowse@iedowse.com) Received: from nowhere.iedowse.com (nowhere.iedowse.com [82.195.144.75]) by mx1.FreeBSD.org (Postfix) with SMTP id 939BB43D69 for ; Sat, 6 Aug 2005 16:02:18 +0000 (GMT) (envelope-from iedowse@iedowse.com) Received: from localhost ([127.0.0.1] helo=iedowse.com) by nowhere.iedowse.com via local-iedowse id ; 6 Aug 2005 17:02:16 +0100 (IST) To: hselasky@c2i.net In-Reply-To: Your message of "Sat, 06 Aug 2005 01:39:55 +0200." <200508060139.57143.hselasky@c2i.net> Date: Sat, 06 Aug 2005 17:02:16 +0100 From: Ian Dowse Message-ID: <200508061702.aa50464@nowhere.iedowse.com> 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 List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Aug 2005 16:02:20 -0000 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. Ian