diff options
Diffstat (limited to 'kern')
-rw-r--r-- | kern/spinlock.h | 18 | ||||
-rw-r--r-- | kern/spinlock_i.h | 6 |
2 files changed, 12 insertions, 12 deletions
diff --git a/kern/spinlock.h b/kern/spinlock.h index cbd95458..8d20db4f 100644 --- a/kern/spinlock.h +++ b/kern/spinlock.h @@ -45,20 +45,20 @@ spinlock_assert_locked(struct spinlock *lock) } /* - * Return true if acquired, false if busy. + * Return 0 on success, 1 if busy. */ static inline int spinlock_trylock(struct spinlock *lock) { - int acquired; + int busy; thread_preempt_disable(); - acquired = spinlock_tryacquire(lock); + busy = spinlock_tryacquire(lock); - if (!acquired) + if (busy) thread_preempt_enable(); - return acquired; + return busy; } static inline void @@ -83,18 +83,18 @@ spinlock_unlock(struct spinlock *lock) static inline int spinlock_trylock_intr_save(struct spinlock *lock, unsigned long *flags) { - int acquired; + int busy; thread_preempt_disable(); *flags = cpu_intr_save(); - acquired = spinlock_tryacquire(lock); + busy = spinlock_tryacquire(lock); - if (!acquired) { + if (busy) { cpu_intr_restore(*flags); thread_preempt_enable(); } - return acquired; + return busy; } static inline void diff --git a/kern/spinlock_i.h b/kern/spinlock_i.h index 58af6bf1..e0d88ba9 100644 --- a/kern/spinlock_i.h +++ b/kern/spinlock_i.h @@ -33,18 +33,18 @@ struct spinlock { }; /* - * Return true if acquired, false if busy. + * Return 0 on success, 1 if busy. */ static inline int spinlock_tryacquire(struct spinlock *lock) { - return !atomic_cas(&lock->locked, 0, 1); + return atomic_cas(&lock->locked, 0, 1); } static inline void spinlock_acquire(struct spinlock *lock) { - while (!spinlock_tryacquire(lock)) + while (spinlock_tryacquire(lock)) cpu_pause(); } |