I was wondering whether all programs run in a Loop, checking for variable changes then acting upon said changes followed by another Loop. Or do they run in a While statement, waiting for a variable to change before they execute a routine? Or am I just completely wrong?
closed as not a real question by Arseni Mourzenko, gnat, Giorgio, Thomas Owens♦ Jun 15 '13 at 12:45
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.
No, not all programs run in a loop. Interactive programs have a main (message) loop to respond to user input.
Programs also run in some sort of loop (
while not Terminated do) when they stay around and wait for input other than user actions. For example HTTP servers that wait for requests to arrive, image processers that wait for files to arrive in a folder, etc.
Programs that take their input parameters, do their thing, report back and then finish, will not run in a loop. That doesn't mean they do not use any loops at all. The work they do may require plenty of loops, but they don't run a loop waiting for more input.
You should learn something about computer science. It will show you that when a program runs, it is the CPU fetch instructions to run. So there is a possibility that cpu do nothing but wait for a intterrupt to wake it up.
The event driven is the best practice nowadays. It costs little and responsive quickly. Though there is not pure event driven os. Linux like OSes use kernel to reponse to interrupts and manage processes by loop-calling schedule method.