Chain loading
This articleneeds additional citations forverification.(October 2013) |
Chain loadingis a method used bycomputer programsto replace the currently executing program with a new program, using acommon data areato pass information from the current program to the new program. It occurs in several areas of computing.
Chain loading is similar to the use ofoverlays.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 theI/Oload of an application.
Chain loading in boot manager programs
[edit]In operating systemboot managerprograms, chain loading is used to pass control from the boot manager to aboot sector.The target boot sector is loaded in fromdisk,replacing the in-memory boot sector from which the boot manager itself was bootstrapped, and executed.
Chain loading in Unix
[edit]InUnix(and inUnix-likeoperating systems), theexec()system call is used to perform chain loading. The program image of the currentprocessis replaced with an entirely new image, and the current thread begins execution of that image. The common data area comprises the process'environment variables,which are preserved across the system call.
Chain loading in Linux
[edit]In addition to theexec()process level chain loadingLinuxsupports thekexec()system call to replace the entire operating systemkernelwith 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
[edit]InBASICprograms, chain loading is the purview of theCHAIN
statement (or, inCommodore BASIC,theLOAD
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 theline numberfrom 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. OnBBC BASIC,for example, only a specific subset of all variables are preserved across a CHAIN. On other BASICs, theCOM
statement[1]can be used in conjunction withCHAIN
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 thatCHAIN
back and forth amongst themselves as program flow moves within the overall application.
Chain loading in FORTRAN programs
[edit]Many versions ofFortraninclude aCALL CHAIN
orCALL LINK
statement that performs chain loading, preserving the contents ofCOMMON storage.[2]This is not the same as the unrelatedLINK
subroutine inGNU Fortran.[3]
Chain loading in OS/360
[edit]OS/360 and successorsuse theXCTL
(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
[edit]- CHAIN (CONFIG.SYS directive)(chain executing multiple CONFIG.SYS files in DR-DOS)
References
[edit]- ^"HP 2000/Access BASIC"(PDF).bitsavers.trailing-edge.HP. pp. 11–25.Retrieved16 January2020.
- ^IBM Corporation (1974).IBM 1130/1800 Basic FORTRAN IV Language(PDF).p. 14.
- ^"The GNU Fortran Compiler".RetrievedOct 27,2013.
- "chain loading".GNU GRUBmanual.
- Orlando Lee Stevenson (December 1985)."Commodore Program Chaining".Compute!(67): 114.
- Raymond, Eric Steven."Multiprogramming: Taxonomy of Unix IPC Methods: Wrappers and Bernstein Chaining".The Art of Unix Programming.