Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Sep 2000 12:40:21 -0700 (PDT)
From:      John Polstra <jdp@polstra.com>
To:        arch@freebsd.org
Cc:        tlambert@primenet.com
Subject:   Re: Mutexes and semaphores (was: cvs commit: src/sys/conf files
Message-ID:  <200009251940.MAA02445@vashon.polstra.com>
In-Reply-To: <200009251931.MAA29117@usr02.primenet.com>
References:  <200009251931.MAA29117@usr02.primenet.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In article <200009251931.MAA29117@usr02.primenet.com>,
Terry Lambert  <tlambert@primenet.com> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200009251940.MAA02445>