3 ms·
These are words that don’t necessarily mean different things. In the broadest sense of mutex and the strictest sense of spinlock, every spinlock is a mutex. Sp
by pizlonator 7y ago
These are words that don’t necessarily mean different things. In the broadest sense of mutex and the strictest sense of spinlock, every spinlock is a mutex.
Spinlock is a mutex algorithm based on spinning until the mutex is available.
Mutex is a MUTual EXclusion abstraction. A spinlock is one implementation. But spinlocks are problematic (for lots of reasons) so most of the time when someone says they’ve got a mutex it’s actually an adaptive lock:
- It has a fast path to acquire the lock.
- It may or may not be fair.
- It has a slow path that may enqueue the thread and deschedule it, but that slow path may have some adaptive spinning for a finite amount of time.