From 9af87a61a58f6149e31f7c7d03aff58b635db126 Mon Sep 17 00:00:00 2001 From: Mariusz Glebocki Date: Fri, 9 Feb 2024 06:08:34 +0100 Subject: [PATCH] Do not spinlock in V3Mutex::lock() --- src/V3Mutex.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/V3Mutex.h b/src/V3Mutex.h index 9f379c0603..5b25b95876 100644 --- a/src/V3Mutex.h +++ b/src/V3Mutex.h @@ -94,14 +94,6 @@ class VL_CAPABILITY("mutex") V3MutexImp final { /// Acquire/lock mutex void lock() VL_ACQUIRE() VL_MT_SAFE { if (V3MutexConfig::s().enable()) { - // Try to acquire the lock by spinning. If the wait is short, - // avoids a trap to the OS plus OS scheduler overhead. - if (VL_LIKELY(try_lock())) return; // Short circuit loop - for (int i = 0; i < VL_LOCK_SPINS; ++i) { - if (VL_LIKELY(try_lock())) return; - VL_CPU_RELAX(); - } - // Spinning hasn't worked, pay the cost of blocking. m_mutex.lock(); } }