From owner-freebsd-smp Tue Oct 10 1:25:21 2000 Delivered-To: freebsd-smp@freebsd.org Received: from smtp03.primenet.com (smtp03.primenet.com [206.165.6.133]) by hub.freebsd.org (Postfix) with ESMTP id 7125237B503; Tue, 10 Oct 2000 01:25:16 -0700 (PDT) Received: (from daemon@localhost) by smtp03.primenet.com (8.9.3/8.9.3) id BAA12092; Tue, 10 Oct 2000 01:23:38 -0700 (MST) Received: from usr06.primenet.com(206.165.6.206) via SMTP by smtp03.primenet.com, id smtpdAAAj8aGHx; Tue Oct 10 01:23:27 2000 Received: (from tlambert@localhost) by usr06.primenet.com (8.8.5/8.8.5) id BAA13123; Tue, 10 Oct 2000 01:24:55 -0700 (MST) From: Terry Lambert Message-Id: <200010100824.BAA13123@usr06.primenet.com> Subject: Re: Mutexes and semaphores To: grog@lemis.com (Greg Lehey) Date: Tue, 10 Oct 2000 08:24:54 +0000 (GMT) Cc: tlambert@primenet.com (Terry Lambert), jhb@FreeBSD.ORG (John Baldwin), eischen@vigrid.com (Daniel Eischen), arch@FreeBSD.ORG, bright@wintelcom.net (Alfred Perlstein), mark@grondar.za (Mark Murray), jburkhol@home.com (Jake Burkholder), bp@butya.kz (Boris Popov), freebsd-smp@FreeBSD.ORG In-Reply-To: <20001007132752.A28665@wantadilla.lemis.com> from "Greg Lehey" at Oct 07, 2000 01:27:52 PM X-Mailer: ELM [version 2.5 PL2] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-smp@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org > > A mutex is not recursive. There are things you simply can not > > implement when recursion is permitted for all of your primitives. > > > > The most obvious argument is still that a mutex is intended to > > protect data, not code. Recursion is only required if the mutex > > is actually protecting reentrancy of code, not access to data. [ ... ] > >> do NOT use printf without Giant. > > > > This strikes me as being rather inane. > > > > If printf won't work without holging the lock, then it damn well > > should acquire the lock if it isn't already held, and release it > > if it acquired it, before returning. > > Make up your mind. I see no conflict. The printf should not fail unless it is the result of a data protection failure. Testing to see that the giant lock (which is not a mutex) is held, if it is truly a requirement to hold it, is not a problem. Acquiring the giant lock only if it is not already acquired, and only releasing it if it wre you who acquired it, is not recursion. Maybe I'm missing some subtlety here that you're not? Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-smp" in the body of the message