Chain loading
Encyclopedia
Chain loading is a method used by computer program
Computer program
A computer program is a sequence of instructions written to perform a specified task with a computer. A computer requires programs to function, typically executing the program's instructions in a central processor. The program has an executable form that the computer can use directly to execute...

s to replace the currently executing program with a new program, using a common data area (a so-called core common area
Core common area
The core common area is that area of a computer program wherein data can remain between the end of execution of one program and the start of execution of a subsequent program in a pipeline....

) to pass information from the current program to the new program. It occurs in several areas of computing.

Chain loading is similar to the use of overlay
Overlay (programming)
In a general computing sense, overlaying means "replacement of a block of stored instructions or data with another" Overlaying is a programming method that allows programs to be larger than the computer's main memory...

s. Like the use of overlays, the use of chain loading increases the I/O
Input/output
In computing, input/output, or I/O, refers to the communication between an information processing system , and the outside world, possibly a human, or another information processing system. Inputs are the signals or data received by the system, and outputs are the signals or data sent from it...

 load of an application. Unlike overlays, however, chain loading replaces the currently executing program in its entirety. Overlays usually replace only a portion of the running program.

Chain loading in boot manager programs

In operating system boot manager programs, chain loading is used to pass control from the boot manager to a boot sector
Boot sector
A boot sector or boot block is a region of a hard disk, floppy disk, optical disc, or other data storage device that contains machine code to be loaded into random-access memory by a computer system's built-in firmware...

. The target boot sector is loaded in from disk
Hard disk
A hard disk drive is a non-volatile, random access digital magnetic data storage device. It features rotating rigid platters on a motor-driven spindle within a protective enclosure. Data is magnetically read from and written to the platter by read/write heads that float on a film of air above the...

, replacing the in-memory boot sector from which the boot manager itself was bootstrapped, and executed.

Chain loading in Unix

In Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

 (and in Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 operating systems), the exec
Overlay (operating system)
In operating systems, an overlay is when a process replaces itself with the code of another program. On Unix-like systems, this is accomplished with the exec system call....

system call is used to perform chain loading. The program image of the current process is replaced with an entirely new image, and the current thread begins execution of that image. The common data area comprises data such as the process' environment variable
Environment variable
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer.They can be said in some sense to create the operating environment in which a process runs...

s, which are preserved across the system call.

This idea is often referred to as Bernstein chaining due to its extensive use by Daniel J. Bernstein
Daniel J. Bernstein
Daniel Julius Bernstein is a mathematician, cryptologist, programmer, and professor of mathematics at the University of Illinois at Chicago...

, but the technique is as old as the getty
Getty (Unix)
getty, short for "get teletype", is a Unix program running on a host computer that manages physical or virtual terminals . When it detects a connection, it prompts for a username and runs the 'login' program to authenticate the user....

and login programs.

Chain loading in BASIC programs

In BASIC programs, chain loading is the purview of the CHAIN statement (or, in Commodore BASIC
Commodore BASIC
Commodore BASIC, also known as PET BASIC, is the dialect of the BASIC programming language used in Commodore International's 8-bit home computer line, stretching from the PET of 1977 to the C128 of 1985...

, the LOAD statement), which causes the current program to be terminated and the chained-to program to be loaded and invoked (with, on those dialects of BASIC that support it, an optional parameter specifying the line number
Line number
In computing, a line number is a method used to specify a particular sequence of characters in a text file. The most common method of assigning numbers to lines is to assign every line a unique number, starting at 1 for the first line, and incrementing by 1 for each successive line.In the C...

 from which execution is to commence, rather than the default of the first line of the new program). The common data area varies according to the particular dialect of BASIC that is in use. On BBC BASIC
BBC BASIC
BBC BASIC is a programming language, developed in 1981 as a native programming language for the MOS Technology 6502 based Acorn BBC Micro home/personal computer, mainly by Sophie Wilson. It is a version of the BASIC programming language adapted for a U.K...

, for example, only a specific subset of all variables are preserved across a CHAIN. On other BASICs, the COMMON statement can be used in conjunction with CHAIN to specify which variables are to be preserved as common data across a chain operation.

Chain loading permits BASIC programs to execute more program code than could fit into available program and variable memory. Applications written in BASIC could thus be far larger than the size of working memory, via a set of cooperating programs that CHAIN back and forth amongst themselves as program flow moves within the overall application.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK