From owner-freebsd-arch Mon Sep 25 12:31:57 2000 Delivered-To: freebsd-arch@freebsd.org Received: from smtp02.primenet.com (smtp02.primenet.com [206.165.6.132]) by hub.freebsd.org (Postfix) with ESMTP id 485D337B440 for ; Mon, 25 Sep 2000 12:31:30 -0700 (PDT) Received: (from daemon@localhost) by smtp02.primenet.com (8.9.3/8.9.3) id MAA19775; Mon, 25 Sep 2000 12:28:37 -0700 (MST) Received: from usr02.primenet.com(206.165.6.202) via SMTP by smtp02.primenet.com, id smtpdAAAimaiAM; Mon Sep 25 12:28:20 2000 Received: (from tlambert@localhost) by usr02.primenet.com (8.8.5/8.8.5) id MAA29117; Mon, 25 Sep 2000 12:31:09 -0700 (MST) From: Terry Lambert Message-Id: <200009251931.MAA29117@usr02.primenet.com> Subject: Re: Mutexes and semaphores (was: cvs commit: src/sys/conf files To: arch@freebsd.org Date: Mon, 25 Sep 2000 19:31:09 +0000 (GMT) Cc: tlambert@primenet.com In-Reply-To: <200009251659.JAA02227@vashon.polstra.com> from "John Polstra" at Sep 25, 2000 09:59:37 AM 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-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > With the suggested mutex recursion (please -- use a counting > > semaphore, not a mutex, if you are going to permit recursion!), > > Please explain why you think a counting semaphore has anything to do > with recursion. To support recursion a mutual exclusion primitive > has to support the concept of ownership. I.e., if you already own > it you can acquire it recursively, but if somebody else owns it then > you cannot. A counting semaphore does not support that concept. The > count is not a recursion count at all. Search google for "counting > semaphore" and you'll find any number of introductory class notes on > semaphores. Or cut right to the chase and go to a typical one at > > http://www.erc.msstate.edu/~ioana/POWERPOINT/CS4163/slides/Threads/tsld022.htm Recursion should be such an exceptional condition that it should be implemented with a seperate struct and a counting semaphore. Counting semaphores have owners,; mutexes do not. Therefore they are a more appropriate primitive. 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-arch" in the body of the message