diff options
author | Tom <tomut@yahoo.com> | 2020-10-27 20:46:32 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-11 12:27:25 +0100 |
commit | b4c9e850560e5b452bd6fd91510ebf944afa5855 (patch) | |
tree | 9be905b9eea2e256f27a3635122f13590454a1f3 /Kernel | |
parent | e26e0445b5b171afc33463f636fef24af858ae3b (diff) | |
download | serenity-b4c9e850560e5b452bd6fd91510ebf944afa5855.zip |
Kernel: Minor SpinLock improvements
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/SpinLock.h | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/Kernel/SpinLock.h b/Kernel/SpinLock.h index d33fbd8685..e2bf8e5daa 100644 --- a/Kernel/SpinLock.h +++ b/Kernel/SpinLock.h @@ -45,10 +45,8 @@ public: { u32 prev_flags; Processor::current().enter_critical(prev_flags); - BaseType expected = 0; - while (!m_lock.compare_exchange_strong(expected, 1, AK::memory_order_acq_rel)) { + while (m_lock.exchange(1, AK::memory_order_acquire) != 0) { Processor::wait_check(); - expected = 0; } return prev_flags; } @@ -62,12 +60,12 @@ public: ALWAYS_INLINE bool is_locked() const { - return m_lock.load(AK::memory_order_consume) != 0; + return m_lock.load(AK::memory_order_relaxed) != 0; } ALWAYS_INLINE void initialize() { - m_lock.store(0, AK::memory_order_release); + m_lock.store(0, AK::memory_order_relaxed); } private: @@ -101,7 +99,7 @@ public: ALWAYS_INLINE void unlock(u32 prev_flags) { ASSERT(m_recursions > 0); - ASSERT(m_lock.load(AK::memory_order_consume) == FlatPtr(&Processor::current())); + ASSERT(m_lock.load(AK::memory_order_relaxed) == FlatPtr(&Processor::current())); if (--m_recursions == 0) m_lock.store(0, AK::memory_order_release); Processor::current().leave_critical(prev_flags); @@ -109,17 +107,17 @@ public: ALWAYS_INLINE bool is_locked() const { - return m_lock.load(AK::memory_order_consume) != 0; + return m_lock.load(AK::memory_order_relaxed) != 0; } ALWAYS_INLINE bool own_lock() const { - return m_lock.load(AK::memory_order_consume) == FlatPtr(&Processor::current()); + return m_lock.load(AK::memory_order_relaxed) == FlatPtr(&Processor::current()); } ALWAYS_INLINE void initialize() { - m_lock.store(0, AK::memory_order_release); + m_lock.store(0, AK::memory_order_relaxed); } private: |