Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Busy waiting
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Continuously checking a condition in computing}} In [[computer science]] and [[software engineering]], '''busy-waiting''', '''busy-looping''' or '''spinning''' is a technique in which a [[process (computing)|process]] repeatedly checks to see if a condition is true, such as whether [[Computer keyboard|keyboard]] input or a [[lock (computer science)|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. Processor speeds vary greatly from computer to computer, especially as some processors are designed to dynamically adjust speed based on current workload.<ref>{{cite web |title=Intel Turbo Boost Technology |url=https://www.intel.com/content/www/us/en/architecture-and-technology/turbo-boost/turbo-boost-technology.html}}</ref> Consequently, spinning as a time-delay technique can produce inconsistent or even unpredictable results on different systems unless code is included to determine the time a processor takes to execute a "do nothing" [[Control flow#Loops|loop]], or the looping code explicitly checks a [[real-time clock]]. In most cases spinning is considered an [[anti-pattern]] and should be avoided,<ref>{{cite web |url=https://www.kernel.org/doc/html/latest/process/volatile-considered-harmful.html |title=Why the 'volatile' type class should not be used |accessdate=2013-06-10 |url-status=live |archiveurl=https://web.archive.org/web/20171004165504/https://www.kernel.org/doc/html/latest/process/volatile-considered-harmful.html |archivedate=2017-10-04 }}</ref> as processor time that could be used to execute a different [[thread (computer science)|task]] is instead wasted on useless activity. Spinning can be a valid strategy in certain circumstances, most notably in the implementation of [[spinlock]]s within operating systems designed to run on [[Symmetric multiprocessing|SMP]] systems.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)