From owner-freebsd-arch Mon Sep 25 13:25: 0 2000 Delivered-To: freebsd-arch@freebsd.org Received: from wall.polstra.com (rtrwan160.accessone.com [206.213.115.74]) by hub.freebsd.org (Postfix) with ESMTP id BF33337B422 for ; Mon, 25 Sep 2000 13:24:57 -0700 (PDT) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.9.3/8.9.3) with ESMTP id NAA17416; Mon, 25 Sep 2000 13:24:54 -0700 (PDT) (envelope-from jdp@polstra.com) From: John Polstra Received: (from jdp@localhost) by vashon.polstra.com (8.9.3/8.9.1) id NAA02690; Mon, 25 Sep 2000 13:24:54 -0700 (PDT) (envelope-from jdp@polstra.com) Date: Mon, 25 Sep 2000 13:24:54 -0700 (PDT) Message-Id: <200009252024.NAA02690@vashon.polstra.com> To: arch@freebsd.org Reply-To: arch@freebsd.org Cc: tlambert@primenet.com Subject: Re: Mutexes and semaphores (was: cvs commit: src/sys/conf files In-Reply-To: <200009252006.NAA00200@usr02.primenet.com> References: <200009252006.NAA00200@usr02.primenet.com> Organization: Polstra & Co., Seattle, WA Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article <200009252006.NAA00200@usr02.primenet.com>, Terry Lambert wrote: > > You are wrong. Counting semaphores do not keep track of owners. > > OK. Let's be pedantic. Neither do mutexes. I didn't say "mutex", I said "recursive mutex". Recursive mutexes do indeed keep track of their owners. > Counting semaphores are a more appropriate primitive, as the > "resource" which is counted is the ownership capability. As > others have pointed out (Archie, etc.), a semaphore with a > count of 1 is appropriate. When the count goes 1->0, then > we can consider that ownership has been relinquished. Actually, when the count goes 1->0, ownership has been acquired, not relinquished. The count represents the number of available units, and that is the case in every definition and every implementation of semaphores I have ever seen (which is quite a few, beginning in the early 70's.). It's even true in the rather baroque implementation of semop(3). > I never stated that the recursion count would be implemented in > the semaphore count of a counting semaphore. Please read the > first quoted sentence again. Ownership and recursion are kept > in the seperate struct. Fine, then you don't need a counting semaphore at all, as a simple non-recursive mutex will do the same job just as well and more efficiently. > To get around this, you have to implement non-recusing mutexes > using a semaphore of count 1. A semaphore with a count of 1, when used for mutual exclusion, behaves exactly the same as a simple mutex. I don't understand why you brought up counting semaphores at all. John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Disappointment is a good sign of basic intelligence." -- Chögyam Trungpa To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message