From owner-freebsd-arch Mon Sep 25 12:40:31 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 E0D4037B43C for ; Mon, 25 Sep 2000 12:40:24 -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 MAA17111; Mon, 25 Sep 2000 12:40:21 -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 MAA02445; Mon, 25 Sep 2000 12:40:21 -0700 (PDT) (envelope-from jdp@polstra.com) Date: Mon, 25 Sep 2000 12:40:21 -0700 (PDT) Message-Id: <200009251940.MAA02445@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: <200009251931.MAA29117@usr02.primenet.com> References: <200009251931.MAA29117@usr02.primenet.com> Organization: Polstra & Co., Seattle, WA Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article <200009251931.MAA29117@usr02.primenet.com>, Terry Lambert wrote: > > 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. You are wrong. Counting semaphores do not keep track of owners. The count has nothing to do with that at all. The count holds the number of available "units" of whatever resource the semaphore is controlling access to. It is the number of "P" operations that can be done without blocking. That is completely different from the recursion count of a recursive mutex, which keeps track of the number of times the current owner has acquired the mutex, and therefore the number of releases the owner must do before somebody else can acquire the mutex. Don't take my word for it. Do the Google search as I suggested, or go to the sample URL I gave you, or read any decent book or tutorial on the subject. Or, since you've cited Windows as having done it right, read their documentation on semaphores. 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