What is a spinlock?
Posted Jan 31, 2003 18:19 UTC (Fri) by cpeterso
In reply to: What is a spinlock?
Parent article: Fast reader/writer locks
With a normal lock, a thread will be put to sleep when it has to wait to obtain the lock. When the lock is available, the thread will be woken up.
As described, a thread will "spin" or "busy-wait" for a spinlock. Thus spinlocks should only be used for very short critical sections. If the spinning thread has to wait a long time, your CPU usage will hit 100% because the spinning thread is executing a very tight loop. That is obviously bad for performance.
to post comments)