Skip to content

Commit

Permalink
Do not spinlock in V3Mutex::lock()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz Glebocki committed Feb 13, 2024
1 parent c2e390b commit 9af87a6
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions src/V3Mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down

0 comments on commit 9af87a6

Please sign in to comment.