Date: Tue, 04 Mar 2003 17:48:59 -0500 (EST) From: John Baldwin <jhb@FreeBSD.org> To: "Brian F. Feldman" <green@FreeBSD.org> Cc: cvs-all@FreeBSD.org, cvs-src@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: cvs commit: src/sys/kern kern_mutex.c Message-ID: <XFMail.20030304174859.jhb@FreeBSD.org> In-Reply-To: <200303042149.h24LnKSQ073292@green.bikeshed.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 04-Mar-2003 Brian F. Feldman wrote: > John Baldwin <jhb@FreeBSD.org> 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 <jhb@FreeBSD.org> <>< 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-src" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20030304174859.jhb>