From owner-freebsd-drivers@FreeBSD.ORG Tue Nov 25 17:22:09 2008 Return-Path: Delivered-To: drivers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 959DE1065672 for ; Tue, 25 Nov 2008 17:22:09 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 5F5788FC08 for ; Tue, 25 Nov 2008 17:22:09 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id mAPHJ0bH060387; Tue, 25 Nov 2008 10:19:00 -0700 (MST) (envelope-from imp@bsdimp.com) Date: Tue, 25 Nov 2008 10:20:30 -0700 (MST) Message-Id: <20081125.102030.-1272479009.imp@bsdimp.com> To: huntting@glarp.com From: "M. Warner Losh" In-Reply-To: <200811251707.mAPH7JRg090619@antediluvian.glarp.com> References: <20081124.134236.723203643.imp@bsdimp.com> <200811251707.mAPH7JRg090619@antediluvian.glarp.com> X-Mailer: Mew version 5.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: drivers@FreeBSD.org Subject: Re: mutex quandry X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Nov 2008 17:22:09 -0000 In message: <200811251707.mAPH7JRg090619@antediluvian.glarp.com> Brad Huntting writes: : : >: The combination of checking sc_running and incrementing sc_inuse : >: needs to be atomic (hence a mutex around them) but at some point : >: detach() has to destroy the mutex but my code may still need to use : >: it. : > : >Your solution to this is to make sure that never happens. Anything : >else is really racy. If you are destroying your mutex and allowing : >detach to return, the entire sc is freed, so you're dead from that : >anyway... : : Fair enough. I guess I was just too focused on my small part of : the larger system. : : But that brings up another issue. How do my (kernel level) users : know if my module is loaded or not? I cant find any section 9 docs : on kernal loadable modules. Am I looking in the wrong place? Or : do I just need to read the source. It should be documented in section 9. Use level users can do a kldstat to find this information. I think kern_kldload will load the module, but I'm not sure how to get status. I've cc'd drivers@ to see if someone there knows. Warner