Spinlock Detection and Correction | Tips & Tricks
The first and most basic question is “What is a spinlock?” The following is from The August 1995 issue of the Sybase Technical News (Vol 4, Number 3): That particular article used the term ‘SQL Server’ to refer to Sybase ASE. Spinlock Defined The lowest level of synchronization in a multiprocessor SQL Server is the spinlock. SQL Server uses the spinlock to synchronize access to the critical data used to control semaphores, page locks, and other thread management tasks. NOTE: Spinlocks and semaphores are only used in multiprocessor servers, since otherwise a process is not allowed to schedule out (or yield) while holding one. In general, a spinlock works like this: 1. A thread or engine obtains a spinlock before attempting to change data. 2. While that thread or engine has the spinlock, if another thread or engine attempts to obtain the same spinlock, that thread “spins” on the lock until the lock is released. 3. Once it is safe for others to access or change the data, the original thread releases the spinlock. A spinlock might perform code protection or data protection. For example, SQL Server always uses one particular spinlock for modifying an object. A spinlock protecting code (more…)