(Translated by https://www.hiragana.jp/)
Chain loading - Wikipedia Jump to content

Chain loading

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Andreas Kaufmann (talk | contribs) at 19:45, 2 May 2011 (removed Category:Computer programming; added Category:Operating system technology using HotCat). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Chain loading is a method used by computer programs to replace the currently executing program with a new program, using a common data area (a so-called core common 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 overlays. Like the use of overlays, the use of chain loading increases the I/O 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. The target boot sector is loaded in from disk, replacing the in-memory boot sector from which the boot manager itself was bootstrapped, and executed.

Chain loading in Unix

In Unix (and in Unix-like operating systems), the exec() 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 variables, 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, but the technique is as old as the getty and login programs.

Chain loading in BASIC programs

In BASIC programs, chain loading is the purview of the CHAIN statement (or, in Commodore BASIC, 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 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, 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.

References

  • "chain loading". GNU GRUB manual.
  • Orlando Lee Stevenson (December 1985). "Commodore Program Chaining". COMPUTE! (67): 114.
  • "Security Wrappers and Bernstein Chaining". Taxonomy of Unix IPC Methods. {{cite web}}: |chapter= ignored (help) in The Art of Unix Programming.