From 983f4f935c4a26d024966896c6ea1ec853d44280 Mon Sep 17 00:00:00 2001 From: Muhammad Zahalqa Date: Wed, 19 Aug 2020 12:10:53 +0300 Subject: [PATCH] Kernel: Do not wait before first attempt at locking SpinLock (#3212) --- Kernel/SpinLock.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Kernel/SpinLock.h b/Kernel/SpinLock.h index 9e171746fd5..d33fbd86853 100644 --- a/Kernel/SpinLock.h +++ b/Kernel/SpinLock.h @@ -45,11 +45,11 @@ public: { u32 prev_flags; Processor::current().enter_critical(prev_flags); - BaseType expected; - do { + BaseType expected = 0; + while (!m_lock.compare_exchange_strong(expected, 1, AK::memory_order_acq_rel)) { Processor::wait_check(); expected = 0; - } while (!m_lock.compare_exchange_strong(expected, 1, AK::memory_order_acq_rel)); + } return prev_flags; }