FACTOID # 55: NationMaster.com is now 40 times the size of the CIA World Factbook!
 
 Home   Encyclopedia   Statistics   Countries A-Z   Flags   Maps   Education   Forum   FAQ   About 
 
WHAT'S NEW
RECENT ARTICLES
More Recent Articles »
 

SEARCH ALL

FACTS & STATISTICS    Advanced view

Search encyclopedia, statistics and forums:

 

 

(* = Graphable)

 

 


Encyclopedia > Infinite loop

An infinite loop is a sequence of instructions in a computer program which loops endlessly, either due to the loop having no terminating condition or having one that can never be met. In older operating systems with cooperative multitasking, infinite loops normally caused the entire system to become unresponsive. With the now-prevalent preemptive multitasking model, infinite loops usually cause the program to consume all available processor time, but can usually be terminated by the user. Busy-wait loops are also sometimes misleadingly called "infinite loops". In computer science control flow (or alternatively, flow of control) refers to the order in which the individual statements or instructions of an imperative program are performed or executed. ... // An operating system (OS) is a set of computer programs that manage the hardware and software resources of a computer. ... In computing, cooperative multitasking (or non-preemptive multitasking) is a form of multitasking in which multiple tasks execute by voluntarily ceding control to other tasks at programmer-defined points within each task. ... In software engineering, busy waiting or spinning is a technique in which a process repeatedly checks to see if a condition is true, such as waiting for keyboard input or waiting for a lock to become available. ...


Like other terms with specific meaning to programmers and an evocative feel (for example memory leak), the term is sometimes used incorrectly; see colloquial use below. An actual infinite loop is something that can generally only be diagnosed by a programmer. In computer science, a memory leak is a particular kind of unintentional memory consumption by a computer program where the program fails to release memory when no longer needed. ...

Contents

Looping

Looping is repeating a set of instructions until a specific condition is met. An infinite loop occurs when the condition will never be met, due to some inherent characteristic of the loop. There are a few situations when this is desired behavior. For example, many server programs such as Internet or database servers loop forever waiting for and servicing requests, though these may not be strictly considered infinite loops, because manual program termination still serves as a condition which exits the loop. Most often, the term is used for those situations when this is not the intended result; that is, when this is a bug. Such errors are most common among novice programmers, but can be made by experienced programmers as well, and their causes can be quite subtle. Client/Server is a network application architecture which separates the client (usually the graphical user interface) from the server. ... A database server is a computer program that provides database services to other computer programs or computers, as defined by the client-server model; the term may also refer to a computer dedicated to running such a program. ... A software bug is an error, flaw, mistake, failure, or fault in a computer program that prevents it from behaving as intended (e. ...


One common cause, for example, is that the programmer intends to iterate over a collection of items such as a linked list, executing the loop code once for each item. Improperly formed links can create a reference loop in the list, causing the code to continue forever because the program never reaches the end of the list. In computer science, a linked list is one of the fundamental data structures used in computer programming. ...


A simple example in BASIC: BASIC (Beginners All-purpose Symbolic Instruction Code) is a family of high-level programming languages. ...

  10 x = x + 1 20 Print x 30 GoTo 10  

Here the loop is quite obvious, as the last line unconditionally sends execution back to the first. Unexpected behavior in evaluating the terminating condition can also cause this problem. Here is an example (in C): C is a general-purpose, block structured, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. ...

  float x = 0.1; while (x != 1.1) { x = x + 0.1; printf("x = %fn", x); }  

On some systems, this loop will execute ten times as expected, but on other systems it will never terminate. The problem is that the loop terminating condition (x != 1.1) tests for exact equality of two floating point values, and the way floating point values are represented in many computers will make this test fail, because they cannot represent the value 1.1 exactly. A floating-point number is a digital representation for a number in a certain subset of the rational numbers, and is often used to approximate an arbitrary real number on a computer. ...


Because of the likelihood of tests for equality or not-equality failing unexpectedly, it is safer to use greater-than or less-than tests when dealing with floating-point values. For example, instead of testing whether x equals 1.1, one might test whether x >= 1.1, or x < 1.2, either of which would be certain to exit after a finite number of iterations. Another way to fix this particular example would be to use an integer as a loop index, counting the number of iterations that have been performed. In computer science, the term integer is used to refer to any data type which can represent some subset of the mathematical integers. ... In computer science control flow (or alternatively, flow of control) refers to the order in which the individual statements or instructions of an imperative program are performed or executed. ...


A similar problem occurs frequently in numerical analysis: in order to compute a certain result, an iteration is intended to be carried out until the error is smaller than a chosen tolerance. However, because of rounding errors during the iteration, the specified tolerance can never be reached, resulting in an infinite loop. Numerical analysis is the study of approximate methods for the problems of continuous mathematics (as distinguished from discrete mathematics). ...


While most infinite loops can be found by close inspection of the code, there is no general method to determine whether a given program will ever halt or will run forever; this is the undecidability of the halting problem. In computability theory and computational complexity theory, a decision problem is a question in some formal system with a yes-or-no answer. ... In computability theory the halting problem is a decision problem which can be informally stated as follows: Given a description of a program and a finite input, decide whether the program finishes running or will run forever, given that input. ...


Multi-party loops

Although infinite loops in a single program are usually easy to predict, a loop caused by interaction of several entities is much harder to foresee. Consider a server that always replies with an error message if it does not understand the request. Apparently, there is no possibility for an infinite loop in the server, but if there are two such servers (A and B), and A receives a message of unknown type from B, then A replies with an error message to B, B does not understand the error message and replies to A with its own error message, A does not understand the error message from B and sends yet another error message, and so on ad infinitum. One common example of such situation is e-mail loop. An E-Mail Loop is an infinite loop phenomenon created by mail servers, scripts, or mail reading programs generating automatic replies or responses, to which each automatic response generates another automatic response and so on. ...


Pseudo-infinite loops

A pseudo-infinite loop is a loop that appears infinite but is really just a very long loop.


Impossible termination condition

An example in C:

 unsigned int i; for (i = 1; i > 0; i++) { loop code } 

It appears that this will go on forever, but in fact the value of i will eventually reach the maximum value storable in an unsigned int and adding 1 to that number will wrap-around to 0, breaking the loop. The actual limit of i depends on the details of the system and compiler used. With arbitrary-precision arithmetic, this loop would continue until the computer's memory could no longer contain i. A diagram of the operation of a typical multi-language, multi-target compiler. ... On a computer, arbitrary-precision arithmetic, also called bignum arithmetic, is a technique that allows computer programs to perform calculations on integers or rational numbers (including floating-point numbers) with an arbitrary number of digits of precision, typically limited only by the available memory of the host system. ... To meet Wikipedias quality standards, this article or section may require cleanup. ...


Infinite recursion

Infinite recursion, a special case of an infinite loop that is caused by recursion. The most trivial example of this is the term Ω in the lambda calculus, shown below in Scheme: A visual form of recursion known as the Droste effect. ... The lambda calculus is a formal system designed to investigate function definition, function application, and recursion. ... Scheme is a multi-paradigm programming language. ...

 (define Ω (let ([ω (lambda (f) (f f))]) (ω ω))) 

Ω is an infinite recursion, and therefore has no normal form. When using structural recursion, infinite recursions are usually caused by a missing base case or by a faulty inductive step. An example of such a faulty structural recursion: The term normal form is used in a variety of contexts. ... Structural induction is a proof method that is used in mathematical logic (e. ...

 (define (sum-from-1-to n) (+ n (sum-from-1-to (sub1 n)))) 

The function sum-from-1-to will run out of stack space, as the recursion never stops — it is infinite. To correct the problem, a base case is added. To meet Wikipedias quality standards, this article or section may require cleanup. ...

 (define (sum-from-1-to' n) (cond [(= n 1) 1] [else (+ n (sum-from-1-to' (sub1 n)))])) 

This revised function will only run out of stack space if n is less than 1 or n is too large; error checking would remove the first case. For information on recursive functions which never run out of stack space, see tail recursion. In computer science, tail recursion is a special case of recursion that can be easily transformed into an iteration. ...


Alderson loop

Main article: Alderson loop

An Alderson loop is a slang or jargon term for a special version of an infinite loop where there is an exit condition available, but inaccessible in the current implementation of the code, typically due to programmer error. These are most common and visible while debugging user interface code. An example would be if there is a menu stating, “Select 1-3 or 9 to quit” and 9 is not allowed by the function that takes the selection from the user. It is generally considered a common type of software bug. The term allegedly received its name from a programmer who had coded a modal message box in Microsoft Access without either an OK or Cancel button, thereby disabling the entire program whenever the box came up.[1] In computer programming, an Alderson loop is a type of infinite loop, where there is an exit condition available, but inaccessible in the current implementation of the code. ... Debugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware thus making it behave as expected. ... The user interface is the part of a system exposed to users. ... A software bug is an error, flaw, mistake, failure, or fault in a computer program that prevents it from behaving as intended (e. ... This article does not cite any references or sources. ...


Colloquial use

Like some other programming terms (for example memory leak) the term 'infinite loop' may be attractive to non-programmers and may be used to describe situations other than programming errors. For example, any computing situation which involves a series of steps and ends up at the starting point, especially if there does not seem to be any way to escape or achieve the desired objective.[2] It may also be used by some to refer to voluntarily setting up anything that repeats.[3] In computer science, a memory leak is a particular kind of unintentional memory consumption by a computer program where the program fails to release memory when no longer needed. ...


See also

GOTO is a command found in many programming languages which instructs the computer to jump to another point in the computer program, specified by a label or line number. ... A visual form of recursion known as the Droste effect. ... It has been suggested that Circular wait be merged into this article or section. ... An infinite loop is a sequence of instructions in a computer program which loops endlessly. ...

References

  1. ^ Alderson Loop The Jargon File, Version 4.4.7. Accessed 5/21/2006. (public domain)
  2. ^ Caught in an infinite loop: colloquial use of the phrase.
  3. ^ Confession of an infinite looper who is in fact just putting a single music track on repeat

  Results from FactBites:
 
Infinite loop - Wikipedia, the free encyclopedia (697 words)
A loop index is a variable that stores the point at which the computer is at in the loop.
While most infinite loops can be found by close inspection of the code, there is no general method to determine whether a given program will ever halt or will run forever; this is the undecidability of the halting problem.
Technically, an infinite loop can only occur in iterative programming, which is programming that repeats itself until some condition is true.
  More results at FactBites »


 

COMMENTARY     


Share your thoughts, questions and commentary here
Your name
Your comments
Please enter the 5-letter protection code

Want to know more?
Search encyclopedia, statistics and forums:

 


Lesson Plans | Student Area | Student FAQ | Reviews | Press Releases |  Feeds | Contact
The Wikipedia article included on this page is licensed under the GFDL.
Images may be subject to relevant owners' copyright.
All other elements are (c) copyright NationMaster.com 2003-5. All Rights Reserved.
Usage implies agreement with terms.