diff options
author | Richard Braun <rbraun@sceen.net> | 2013-04-03 20:58:54 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2013-04-03 20:58:54 +0200 |
commit | 9ca509a21cdb2ee412b62ba264704ce0d7fda4c4 (patch) | |
tree | c686e8792ce70ada2694af958696c11008389bba /kern/spinlock.h | |
parent | 5f0401fd56a2dc980def9c381a8248a5b61c45a9 (diff) |
kern/spinlock: change the interface of trylock functions
Make trylock functions behave as error-returning functions.
Diffstat (limited to 'kern/spinlock.h')
-rw-r--r-- | kern/spinlock.h | 18 |
1 files changed, 9 insertions, 9 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 |