From owner-cvs-all Tue Mar 4 14:49:26 2003 Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2E0D437B401 for ; Tue, 4 Mar 2003 14:49:24 -0800 (PST) Received: from mail.speakeasy.net (mail16.speakeasy.net [216.254.0.216]) by mx1.FreeBSD.org (Postfix) with ESMTP id 238E143FBF for ; Tue, 4 Mar 2003 14:49:22 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: (qmail 2476 invoked from network); 4 Mar 2003 22:49:27 -0000 Received: from unknown (HELO server.baldwin.cx) ([216.27.160.63]) (envelope-sender ) by mail16.speakeasy.net (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 4 Mar 2003 22:49:27 -0000 Received: from laptop.baldwin.cx (gw1.twc.weather.com [216.133.140.1]) by server.baldwin.cx (8.12.6/8.12.6) with ESMTP id h24MkHhT046408; Tue, 4 Mar 2003 17:46:30 -0500 (EST) (envelope-from jhb@FreeBSD.org) Message-ID: X-Mailer: XFMail 1.5.2 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <200303042149.h24LnKSQ073292@green.bikeshed.org> Date: Tue, 04 Mar 2003 17:48:59 -0500 (EST) From: John Baldwin To: "Brian F. Feldman" Subject: Re: cvs commit: src/sys/kern kern_mutex.c Cc: cvs-all@FreeBSD.org, cvs-src@FreeBSD.org, src-committers@FreeBSD.org Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On 04-Mar-2003 Brian F. Feldman wrote: > John Baldwin wrote: >> jhb 2003/03/04 13:32:25 PST >> >> FreeBSD src repository >> >> Modified files: >> sys/kern kern_mutex.c >> Log: >> Remove safety belt: it is now ok to do a mtx_trylock() on a mutex you >> already own. The mtx_trylock() will fail however. Enhance the comment >> at the top of the try lock function to explain this. >> >> Requested by: jlemon and his evil netisr locking > > I admit I've never actually had a use for mtx_trylock() but... wouldn't you > like to detect it and assert against it if you're not expecting it? If > jlemon's behavior is the only one that relies on that part of the semantics, > perhaps it should be another kind of mtx_trylock() call. I guess the real > question is just whether or not the assert would ever have done good for > anyone while working. I've used trylock before, see the evilness where we choose which process to kill when we are out of memory. In that case I knew that I didn't already own the lock though. It is not that we didn't expect people to call trylock() with a mutex they already hold. Prior to jlemon's comment I had just assumed that if you ran into that, you probably had a bug. BSD/OS doesn't allow you to call trylock() on a lock you already own which is where we got this assertion from IIRC. You are still free to stick a mtx_assert(&foo, MA_NOTOWNED) in front of your own trylock()'s if you wish. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message