Can it be a loop with or without statements?
while (1)
{
//Empty
}
OR
int i = 0;
while (1)
{
i++;
}
See Question&Answers more detail:osCan it be a loop with or without statements?
while (1)
{
//Empty
}
OR
int i = 0;
while (1)
{
i++;
}
See Question&Answers more detail:osA "busy loop" or more commonly "busy wait" is an active polling where the application is waiting on some event to occur and continuously checks for it. Typically this includes a timed sleep or other task which gives up CPU time so that another process can provide the expected input.
Contrast this with a callback. While waiting on a callback, the program consumes no CPU cycles. Typically the program will "register" a callback routine which some monitoring application invokes based on some event.
The distinction is that the program in a busy-loop consumes CPU and time slices while waiting while the callback mechanism allows a program to consume no (or almost no) CPU while waiting.