Talk:Busy waiting

message: Someone needs to explain the use of uptime for non-Unix folks. 218.102.220.129 12:17, 24 May 2006 (UTC)
thread_title:  Non-Unix Explanation 

message: I just noticed another bug besides the ones already pointed out. Maybe this is what the terse "Example" above was implying. If the thread that is supposed to set i to something other than 0 (the "writer") happens to be running on the same core as the one that checks the variable, the polling loop can lock out the writer forever. Many systems give all the threads some time automatically, but that is by no means guaranteed.  — Preceding unsigned comment added by Jive Dadson (talk • contribs) 03:52, 19 August 2012 (UTC)
thread_title:  Another reason the code is broken 

message: Someone who has the time could find an example in the Boost library. The copyright for Boost would allow its inclusion here provided there is a link to the copyright itself. Boost is very well tested.
In the meantime, the current example should be removed. Jive Dadson (talk) 04:21, 19 August 2012 (UTC)
thread_title:  Suggestion for a correct new example 

message: Yet another error in the example: the variable i value is not stored in f1, so if the writer makes two assignments in short time
    i = 99;
    ....
    i = 0;
then the reader may notice the change, but print-out that the value changed from zero to ...zero.
It should rather be something like
static void *f1(void *p)
{
    int i_copy;
    while ((i_copy = i)==0) {
        /* do nothing - just keep checking over and over */
    } 
    printf("i's value has changed to %d.\n", i_copy);
    return NULL;
}
Of course that does not guarantee the reader will notice the change, however if it does, it will at least print the correct message. --CiaPan (talk) 07:04, 6 August 2015 (UTC)
thread_title:  Another error - variable not stored 

message: There is a sleep call in the loop. Why the claim 'wasting CPU resources' then? What is busy in it? Seems to me this is polling.  — Preceding unsigned comment added by Midiparse (talk • contribs) 16:35, 17 January 2017 (UTC)
replies: text: There are three threads operating at the same time: f1() is the one wasting CPU resources: while (i==0) {} will poll the variable i in an infinite loop with no delay, using 100% of its allowed CPU resources, until f2() (which sleeps for 60 seconds and takes no CPU resources) wakes up independently and changes i.  main() just launches f1() and f2() then waits for them with pthread_join(), so it's sleeping also until f1() and f2() end. --Closeapple (talk) 10:04, 19 January 2017 (UTC)
thread_title:  Why is this busy? 

message: Should there be some mention of microcontrollers in this article?
It seems busy waiting is fairly common on microcontrollers, where it's not considered an anti-pattern because the power usage is not significantly increased and there are no other threads/processes to run or take processing resources from. Here's an example of discussion about a busy wait used just to halt a program on Arduino. Polling and other similar busy wait style loops are also common and generally don't seem to be considered bad form. —Pengo 01:32, 20 March 2017 (UTC)
thread_title:  Busy waiting on microcontrollers 

message: Hello fellow Wikipedians,
I have just modified 2 external links on Busy waiting. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:
*Added archive https://web.archive.org/web/20131005133753/https://www.kernel.org/doc/Documentation/volatile-considered-harmful.txt to https://www.kernel.org/doc/Documentation/volatile-considered-harmful.txt
*Added archive https://web.archive.org/web/20041211235628/http://www.codeproject.com/threads/spinlocks.asp to http://codeproject.com/threads/spinlocks.asp
When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.
Cheers.—InternetArchiveBot (Report bug) 02:35, 15 December 2017 (UTC)
thread_title:  External links modified 

message: Back in the day, a lot of MS-DOS games (probably mostly shareware/freeware/PD) used spinning as a time-delay technique, with the consequence that they would run at the correct speed only on a CPU of the same speed as the one they were built and tested on.
But there is something else I'm wondering.  Do some compilers just optimise away a do-nothing loop, such that there will be no time delay at all? — Smjg (talk) 09:29, 5 June 2024 (UTC)
thread_title:  As a time-delay technique