Date: Thu, 14 Aug 1997 12:05:09 -0600 From: Steve Passe <smp@csn.net> To: Poul-Henning Kamp <phk@dk.tfs.com> Cc: smp@freebsd.org Subject: Re: bug ? Message-ID: <199708141805.MAA02086@Ilsa.StevesCafe.com> In-Reply-To: Your message of "Thu, 14 Aug 1997 17:07:57 %2B0200." <3398.871571277@critter.dk.tfs.com>
index | next in thread | previous in thread | raw e-mail
Hi,
>
> this is from sys/kern/kern_lock.c, isn't line 76 & 77 bogus ?
>
> 64 | */
> 65 | int lock_wait_time = 100;
> 66 | #define PAUSE(lkp, wanted) \
> 67 | if (lock_wait_time > 0) { \
> 68 | int i; \
> 69 | \
> 70 | simple_unlock(&lkp->lk_interlock); \
> 71 | for (i = lock_wait_time; i > 0; i--) \
> 72 | if (!(wanted)) \
> 73 | break; \
> 74 | simple_lock(&lkp->lk_interlock); \
> 75 | } \
> 76 | if (!(wanted)) \
> 77 | break;
> 78 |
> 79 | #else /* NCPUS == 1 */
I think it's necessary. In a multiprocessor system there is a chance
another CPU could grab the lock between lines 73 & 74. So line 76 is a
test to guarantee that its still "!(wanted)" after re-acquiring the
simple_lock. There is also the possibility that you timeout without getting
"wanted", line 76 deals with this.
--
Steve Passe | powered by
smp@csn.net | Symmetric MultiProcessor FreeBSD
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199708141805.MAA02086>
