Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Sep 2000 19:34:14 -0400 (EDT)
From:      Bosko Milekic <bmilekic@technokratis.com>
To:        Terry Lambert <tlambert@primenet.com>
Cc:        freebsd-arch@FreeBSD.ORG
Subject:   Re: spinlocks and acquire pseudo-priority
Message-ID:  <Pine.BSF.4.21.0009281931550.4456-100000@jehovah.technokratis.com>
In-Reply-To: <200009280829.BAA11680@usr02.primenet.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Thu, 28 Sep 2000, Terry Lambert wrote:

> The simple answer is "use "for(;;)" instead of something with a
> loop index".
> 
> The fact is, there is just as much probability of C losing a
> race with B for a contended resource formerly held by A under
> normal circumstances, as there is for it losing because of the
> conditions which you describe.
> 
> The answer is: it doesn't matter -- you only ever use a spinlock
> to do one of two things:
> 
> 1)	Eat the overhead of a heavyweight non-spinning lock
> 
> 2)	Contend a resource which will be available in a small
> 	amount of time anyway, so it doesn't matter whether
> 	you get it first or second
> 
> If you really cared about FIFO, FILO, or prioritization or some
> other policy based ordering on lock acquisition, you would not
> use spinlocks; you would use turnstiles and "wake one", or you
> would use some other policy cognizant mechanism for doing the
> granting.
> 
> FWIW, this means you wouldn't use a mutex, either.
> 
> 
> 					Terry Lambert
> 					terry@lambert.org
> ---
> Any opinions in this posting are my own and not those of my present
> or previous employers.

	The problem is not the semantics of a spin lock. The problem is that
  there are "tolerance" numbers which are clearly not acceptable for
  machines with multiple CPUs. The numbers should at least be scaled such
  that they are multiplied by the number of CPUs.
  	For your information, a for(;;) loop is being used. The index is
  there just to be able to tell what iteration we're at and to panic() if
  we've iterated for what we think is too long.

  Cheers,
  Bosko Milekic
  bmilekic@technokratis.com




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?Pine.BSF.4.21.0009281931550.4456-100000>