diff options
author | alc <alc@FreeBSD.org> | 1999-11-11 03:02:03 +0000 |
---|---|---|
committer | alc <alc@FreeBSD.org> | 1999-11-11 03:02:03 +0000 |
commit | b0da33f4f5fc4674189c8d6a20cc7c57cc57edc8 (patch) | |
tree | 320429b6f366606616dfff7f20e4e73e46c2d657 /sys/kern | |
parent | 86a6663de4a17637ca66b480558d67a0a30ea44d (diff) | |
download | FreeBSD-src-b0da33f4f5fc4674189c8d6a20cc7c57cc57edc8.zip FreeBSD-src-b0da33f4f5fc4674189c8d6a20cc7c57cc57edc8.tar.gz |
Correct a locking error in apause: It should always hold
the simple lock when it returns.
Also, eliminate spinning on a uniprocessor. It's pointless.
Submitted by: bde,
Assar Westerlund <assar@sics.se>
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_lock.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c index 2b4cef1..d80561d 100644 --- a/sys/kern/kern_lock.c +++ b/sys/kern/kern_lock.c @@ -103,23 +103,25 @@ shareunlock(struct lock *lkp, int decr) { * optimization troubles. */ static int -apause(struct lock *lkp, int flags) { - int lock_wait; - lock_wait = LOCK_WAIT_TIME; - for (; lock_wait > 0; lock_wait--) { - int i; - if ((lkp->lk_flags & flags) == 0) - return 0; +apause(struct lock *lkp, int flags) +{ +#ifdef SMP + int i, lock_wait; +#endif + + if ((lkp->lk_flags & flags) == 0) + return 0; +#ifdef SMP + for (lock_wait = LOCK_WAIT_TIME; lock_wait > 0; lock_wait--) { simple_unlock(&lkp->lk_interlock); - for (i = LOCK_SAMPLE_WAIT; i > 0; i--) { - if ((lkp->lk_flags & flags) == 0) { - simple_lock(&lkp->lk_interlock); - if ((lkp->lk_flags & flags) == 0) - return 0; + for (i = LOCK_SAMPLE_WAIT; i > 0; i--) + if ((lkp->lk_flags & flags) == 0) break; - } - } + simple_lock(&lkp->lk_interlock); + if ((lkp->lk_flags & flags) == 0) + return 0; } +#endif return 1; } |