??? 05/29/10 12:18 Read: times |
#176293 - Avoid infinite loops like the plague Responding to: ???'s previous message |
Potentially infinite loops should be avoided at (almost) all costs.
The main loop is an unconditional infinite loop. You may have infinite loops while waiting for a watchdog to kick in and reset the processor. Just about any other loop should have one or more well-defined ways to terminate. Waiting for an external event to "maybe" happen is not a well-defined way to terminate. There should also be timeouts or other events that may terminate the loop, to make sure that the code doesn't get stuck until the power is removed or the device receives exessive amounts of ESD or EMP. |