Are spin waits, spin loop and busy spin a different name for the same situation?
I read different threads and they all seem related to a loop that is "busy" checking for the availability of a resource.
Are spin waits, spin loop and busy spin a different name for the same situation?
I read different threads and they all seem related to a loop that is "busy" checking for the availability of a resource.
Busy Spin
A technique which is used in a way that it loop is running until other thread have to complete his work.
Spin Wait
A spin wait that you have to wait until condition for thread is true.
Spin Loop
Spin loop is also similar to both of above busy spin and wait spin. It means that threads have to wait for other thread for completing his work.
By the way I think these terms can also use interchangeably. Precisely these are the same terms.
These three terms refer to the same concept. E.g., we can notice spin wait, spin loop, busy spin and busy wait all being mentioned interchangeably in this SO thread:
What is busy spin in a multi-threaded environment?
Spin Waiting is that you constantly wait for a condition comes true.
LMAX Disrupter framework, a high-performance inter-thread messaging library has a BusySpinWaitStrategy which is based on this concept and uses a busy spin loop for EventProcessors waiting on the barrier.
Busy spin is one of the techniques to wait for events without releasing CPU.
On busy waiting a program idles actively using special op codes like HLT or NOP or other time consuming operations. Other use just a while loop checking for a condition comming true.
You can read more about it in many such places, including the Wikipedia page for "Busy waiting":
https://en.wikipedia.org/wiki/Busy_waiting
In computer science and software engineering, busy-waiting, busy-looping or spinning is a technique in which a process repeatedly checks to see if a condition is true, such as whether keyboard input or a lock is available. Spinning can also be used to generate an arbitrary time delay, a technique that was necessary on systems that lacked a method of waiting a specific length of time.
In most cases spinning is considered an anti-pattern and should be avoided, as processor time that could be used to execute a different task is instead wasted on useless activity. Spinning can be a valid strategy in certain circumstances, most notably in the implementation of spinlocks within operating systems designed to run on SMP systems.
© 2022 - 2024 — McMap. All rights reserved.