In computing, a lock which causes a thread to loop continuously
This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed. Find sources: "Spinlock" – news · newspapers · books · scholar · JSTOR(October 2012) (Learn how and when to remove this message)
In software engineering, a spinlock is a lock that causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking whether the lock is available. Since the thread remains active but is not performing a useful task, the use of such a lock is a kind of busy waiting. Once acquired, spinlocks will usually be held until they are explicitly released, although in some implementations they may be automatically released if the thread being waited on (the one that holds the lock) blocks or "goes to sleep".
Because they avoid overhead from operating system process rescheduling or context switching, spinlocks are efficient if threads are likely to be blocked for only short periods. For this reason, operating-system kernels often use spinlocks. However, spinlocks become wasteful if held for longer durations, as they may prevent other threads from running and require rescheduling. The longer a thread holds a lock, the greater the risk that the thread will be interrupted by the OS scheduler while holding the lock. If this happens, other threads will be left "spinning" (repeatedly trying to acquire the lock), while the thread holding the lock is not making progress towards releasing it. The result is an indefinite postponement until the thread holding the lock can finish and release it. This is especially true on a single-processor system, where each waiting thread of the same priority is likely to waste its quantum (allocated time where a thread can run) spinning until the thread that holds the lock is finally finished.
Implementing spinlocks correctly is challenging because programmers must take into account the possibility of simultaneous access to the lock, which could cause race conditions. Generally, such an implementation is possible only with special assembly language instructions, such as atomic (i.e. un-interruptible) test-and-set operations and cannot be easily implemented in programming languages not supporting truly atomic operations.[1] On architectures without such operations, or if high-level language implementation is required, a non-atomic locking algorithm may be used, e.g. Peterson's algorithm. However, such an implementation may require more memory than a spinlock, be slower to allow progress after unlocking, and may not be implementable in a high-level language if out-of-order execution is allowed.
^Silberschatz, Abraham; Galvin, Peter B. (1994). Operating System Concepts (Fourth ed.). Addison-Wesley. pp. 176–179. ISBN 0-201-59292-4.
In software engineering, a spinlock is a lock that causes a thread trying to acquire it to simply wait in a loop ("spin") while repeatedly checking whether...
Spinlock is a technology based company specialized in the manufacture and development of nuclear magnetic resonance (NMR) and nuclear quadrupole resonance...
strategy in certain circumstances, most notably in the implementation of spinlocks within operating systems designed to run on SMP systems. The following...
is a synchronization mechanism, or locking algorithm, that is a type of spinlock that uses "tickets" to control which thread of execution is allowed to...
a part of artillery fuze mechanism which arms the munition upon firing Spinlock, a concept in multithread programming This disambiguation page lists articles...
the dumbbell and secured with clips or collars. Shown to the right is a "spinlock" dumbbell, whose ends are threaded to accept large nuts as collars. Alternatively...
become ready to run after being blocked in a particular situation, then spinlocks are an acceptable solution (for that situation only).[citation needed]...
includes two more lightweight mutual exclusion solutions—latches and spinlocks—which are less robust than locks but are less resource intensive. SQL...
though more permanent fixings are available. Other variations include spinlock end bars with screw on nut collars and many others. The thickness of the...
inactive (used with floating-point unit) 0x9B XCHG Exchange data r :=: r/m; A spinlock typically uses xchg as an atomic operation. (coma bug). 0x86, 0x87, 0x91...
variables Synchronization between threads using read write locks and barriers Spinlocks The POSIX semaphore API works with POSIX threads but is not part of the...
control. They are used for testing CPUs, for example, when overclocking. Spinlock in a poorly written program may cause similar symptoms, if it lasts sufficiently...
types (which can only be manipulated by a set of specific operators), spinlocks, semaphores, mutexes,: 176–198 and lockless algorithms (e.g., RCUs)....
original on 29 July 2017. Retrieved 20 November 2016. "Bodymax 6 ft Standard Spinlock Barbell with collars". Powerhouse Fitness. Archived from the original on...
user to either respond to a prompt to continue, or reset the device. Spinlocks are low-level synchronization mechanisms used in concurrent programming...
debugger is slow enough to make the read race occur always. Synchronization Spinlock fast reader/writer lock for gettimeofday 2.5.30 Effective synchronisation...