Chain loading is a method used by
computer program
A computer program is a sequence or set of instructions in a programming language for a computer to execute. Computer programs are one component of software, which also includes documentation and other intangible components.
A computer program ...
s to replace the currently executing program with a new program, using a
common data area 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 may refer to:
Computers
*Overlay network, a computer network which is built on top of another network
*Hardware overlay, one type of video overlay that uses memory dedicated to the application
*Another term for exec, replacing one process ...
s. Unlike overlays, however, chain loading replaces the currently executing program in its entirety. Overlays usually replace only a portion of the running program. Like the use of overlays, the use of chain loading increases the
I/O load of an application.
Chain loading in boot manager programs
In operating system
boot manager
A bootloader, also spelled as boot loader or called boot manager and bootstrap loader, is a computer program that is responsible for booting a computer.
When a computer is turned off, its softwareincluding operating systems, application code, an ...
programs, chain loading is used to pass control from the boot manager to a
boot sector. The target boot sector is loaded in from
disk
Disk or disc may refer to:
* Disk (mathematics), a geometric shape
* Disk storage
Music
* Disc (band), an American experimental music band
* ''Disk'' (album), a 1995 EP by Moby
Other uses
* Disk (functional analysis), a subset of a vector sp ...
, replacing the in-memory boot sector from which the boot manager itself was bootstrapped, and executed.
Chain loading in Unix
In
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and ot ...
(and in
Unix-like
A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating systems), the
exec() system call is used to perform chain loading. The program image of the current
process
A process is a series or set of activities that interact to produce a result; it may occur once-only or be recurrent or periodic.
Things called a process include:
Business and management
*Business process, activities that produce a specific se ...
is replaced with an entirely new image, and the current thread begins execution of that image. The common data area comprises the process'
environment variable
An environment variable is a dynamic-named value that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs. For example, a running process can query the value of the TEMP env ...
s, which are preserved across the system call.
Chain loading in Linux
In addition to the process level chain loading
Linux
Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, which ...
supports the system call to replace the entire operating system
kernel
Kernel may refer to:
Computing
* Kernel (operating system), the central component of most operating systems
* Kernel (image processing), a matrix used for image convolution
* Compute kernel, in GPGPU programming
* Kernel method, in machine learnin ...
with a different version. The new kernel boots as if it were started from power up and no running processes are preserved.
Chain loading in BASIC programs
In
BASIC
BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
programs, chain loading is the purview of the
CHAIN
statement (or, in
Commodore BASIC
Commodore BASIC, also known as PET BASIC or CBM-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 core is based on 6502 M ...
, 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
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 increm ...
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 is a version of the BASIC programming language released in 1981 as the native programming language for the BBC Micro home/personal computer, providing a standardized language for a UK computer literacy project of the BBC. It was wri ...
, for example, only a specific subset of all variables are preserved across a CHAIN. On other BASICs, the
COM
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.
Chain loading in FORTRAN programs
Many versions of
Fortran include a
CALL CHAIN
or
CALL LINK
statement that performs chain loading, preserving the contents of
COMMON storage. This is not the same as the unrelated
LINK
subroutine in
GNU Fortran
GNU Fortran or GFortran is the GNU Fortran compiler, which is part of the GNU Compiler Collection (GCC).
It includes full support for the Fortran#Fortran 95, Fortran 95 language, and supports large parts of the Fortran#Fortran 2003, Fortran 2003 an ...
.
Chain loading in OS/360
OS/360 and successors
OS/360, officially known as IBM System/360 Operating System, is a discontinued batch processing operating system developed by IBM for their then-new System/360 mainframe computer, announced in 1964; it was influenced by the earlier IBSYS/IBJOB ...
use the
XCTL
(for "transfer control") macro for chain loading. Because of the
operating system's memory management this may or may not result in replacement of the code of the calling program in memory.
See also
*
CHAIN (CONFIG.SYS directive)
CONFIG.SYS is the primary configuration file for the DOS and OS/2 operating systems. It is a special ASCII text file that contains user-accessible setup or configuration directives evaluated by the operating system's DOS BIOS (typically residing ...
(chain executing multiple CONFIG.SYS files in DR-DOS)
References
*
*
* {{citation , mode=cs1 , chapter-url=http://www.faqs.org/docs/artu/ch07s02.html , title=
The Art of Unix Programming
''The Art of Unix Programming'' by Eric S. Raymond is a book about the history and culture of Unix programming from its earliest days in 1969 to 2003 when it was published, covering both genetic derivations such as BSD and conceptual ones such a ...
, first=Eric Steven , last=Raymond , chapter=Multiprogramming: Taxonomy of Unix IPC Methods: Wrappers and Bernstein Chaining
Operating system technology
Process (computing)