diff options
author | Richard Braun <rbraun@sceen.net> | 2012-12-11 21:42:05 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2012-12-11 21:42:05 +0100 |
commit | 49e0754e29947dbed6f9cb40a8ef881efaac0e00 (patch) | |
tree | 02751ffb4f80d567f3435a7ae618dfb78c5d864c | |
parent | e5ec4d80124941499979fdd035c5170490b80b5d (diff) |
kern/spinlock: minor changes
-rw-r--r-- | kern/spinlock.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/kern/spinlock.h b/kern/spinlock.h index ba8b3a8a..ccd2cc60 100644 --- a/kern/spinlock.h +++ b/kern/spinlock.h @@ -83,7 +83,7 @@ spinlock_lock(struct spinlock *lock) { thread_preempt_disable(); - while (atomic_cas(&lock->locked, 0, 1)) + while (atomic_cas(&lock->locked, 0, 1) != 0) cpu_pause(); } @@ -93,7 +93,10 @@ spinlock_lock(struct spinlock *lock) static inline void spinlock_unlock(struct spinlock *lock) { - atomic_swap(&lock->locked, 0); + unsigned long locked; + + locked = atomic_swap(&lock->locked, 0); + assert(locked); thread_preempt_enable(); } |