Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 25 Sep 2000 22:35:28 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        arch@freebsd.org
Cc:        tlambert@primenet.com
Subject:   Re: Mutexes and semaphores (was: cvs commit: src/sys/conf files
Message-ID:  <200009252235.PAA07367@usr07.primenet.com>
In-Reply-To: <200009252024.NAA02690@vashon.polstra.com> from "John Polstra" at Sep 25, 2000 01:24:54 PM

next in thread | previous in thread | raw e-mail | index | archive | help
> > 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).

Remaining resources vs. acquired resources.  Same difference,
you knew what I meant, which is what mattered.


> 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.

Fine.  Then we're agreed: non-recursive mutexes are the base
unit, and recursion will be implemented on a case by case basis
using an additional structure, which contains a non-recursive
mutex, a recursion counter, and an owner field.

Glad that's settled, until the first time a thread migrates between
processors, and we decide we need a semaphore instead of a mutex
as a primitive in order to handle sleeps and wakeups that occur
with a mutex with a recursion count greater than 0, for some ungodly
reason.


					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




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