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

Chain loading: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m clean up
 
(26 intermediate revisions by 21 users not shown)
Line 1: Line 1:
{{refimprove|date=October 2013}}
{{more citations needed|date=October 2013}}
'''Chain loading''' is a method used by [[computer program]]s 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 a method used by [[computer program]]s to replace the currently executing program with a new program, using a [[core common area|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 (programming)|overlay]]s. Like the use of overlays, the use of chain loading increases the [[Input/output|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 is similar to the use of [[overlay (programming)|overlay]]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 [[Input/output|I/O]] load of an application.


== Chain loading in boot manager programs ==
== Chain loading in boot manager programs ==
Line 8: Line 8:


== Chain loading in Unix ==
== Chain loading in Unix ==
In [[Unix]] (and in [[Unix-like]] operating systems), the <tt>[[Overlay (operating system)|exec()]]</tt> system call is used to perform chain loading. The program image of the current [[computer process|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]]s, which are preserved across the system call.
In [[Unix]] (and in [[Unix-like]] operating systems), the [[exec (system call)|exec()]] system call is used to perform chain loading. The program image of the current [[computer process|process]] 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]]s, which are preserved across the system call.

== Chain loading in Linux ==
In addition to the {{mono|exec()}} process level chain loading [[Linux]] supports the {{mono|[[kexec]]()}} system call to replace the entire operating system [[Kernel (operating system)|kernel]] 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 ==
== Chain loading in BASIC programs ==
In [[BASIC programming language|BASIC]] programs, chain loading is the purview of the <code>CHAIN</code> statement (or, in [[Commodore BASIC]], the <code>LOAD</code> 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 <code>COMMON</code> statement can be used in conjunction with <code>CHAIN</code> to specify which variables are to be preserved as common data across a chain operation.
In [[BASIC programming language|BASIC]] programs, chain loading is the purview of the <code>CHAIN</code> statement (or, in [[Commodore BASIC]], the <code>LOAD</code> 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 <code>COM</code> statement<ref name="TSB2000">{{cite web |title=HP 2000/Access BASIC |url=http://bitsavers.trailing-edge.com/pdf/hp/2000TSB/22687-90001_AccessBasic9-75.pdf |website=bitsavers.trailing-edge.com |publisher=HP |accessdate=16 January 2020 |pages=11–25}}</ref> can be used in conjunction with <code>CHAIN</code> 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 <code>CHAIN</code> back and forth amongst themselves as program flow moves within the overall application.
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 <code>CHAIN</code> back and forth amongst themselves as program flow moves within the overall application.


== Chain loading in FORTRAN programs ==
== Chain loading in FORTRAN programs ==
Many versions of Fortran include a <code>CALL LINK</code> statement that performs chain loading, preserving the contents of COMMON storage.<ref>{{cite book|last=IBM Corporation|title=IBM 1130/1800 Basic FORTRAN IV Language|year=1974|page=14|url=http://bitsavers.trailing-edge.com/pdf/ibm/1130/lang/GC26-3715-8_1130_1800_Basic_FORTRAN_IV_Language_Jan73.pdf}}</ref> This is not the same as the unrelated <code>LINK</code> subroutine in [[gfortran|Gnu Fortran]].<ref>{{cite web|title=The GNU Fortran Compiler|url=http://gcc.gnu.org/onlinedocs/gfortran/LINK.html|accessdate=Oct 27, 2013}}</ref>
Many versions of [[Fortran]] include a <code>CALL CHAIN</code> or <code>CALL LINK</code> statement that performs chain loading, preserving the contents of [[Core common area|COMMON storage]].<ref>{{cite book|last=IBM Corporation|title=IBM 1130/1800 Basic FORTRAN IV Language|year=1974|page=14|url=http://bitsavers.trailing-edge.com/pdf/ibm/1130/lang/GC26-3715-8_1130_1800_Basic_FORTRAN_IV_Language_Jan73.pdf}}</ref> This is not the same as the unrelated <code>LINK</code> subroutine in [[GNU Fortran]].<ref>{{cite web|title=The GNU Fortran Compiler|url=https://gcc.gnu.org/onlinedocs/gfortran/LINK.html|accessdate=Oct 27, 2013}}</ref>

== Chain loading in OS/360 ==
[[OS/360 and successors]] use the <code>XCTL</code> (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)]] (chain executing multiple CONFIG.SYS files in DR-DOS)


== References ==
== References ==
{{Reflist}}
{{Reflist}}
* {{cite web|url=http://www.gnu.org/software/grub/manual/html_node/Chain_002dloading.html|title=chain loading|work=[[GNU GRUB]] manual}}
* {{cite web|url=https://www.gnu.org/software/grub/manual/html_node/Chain_002dloading.html|title=chain loading|work=[[GNU GRUB]] manual}}
* {{cite journal|url=http://www.atarimagazines.com/compute/issue67/341_1_Commodore_Program_Chaining.php|title=Commodore Program Chaining|author=Orlando Lee Stevenson|journal=COMPUTE!|issue=67|date=December 1985|pages=114}}
* {{cite journal|url=http://www.atarimagazines.com/compute/issue67/341_1_Commodore_Program_Chaining.php|title=Commodore Program Chaining|author=Orlando Lee Stevenson|journal=Compute!|issue=67|date=December 1985|pages=114}}
* {{cite web|url=http://www.faqs.org/docs/artu/ch07s02.html|title=Security Wrappers and Bernstein Chaining|work=Taxonomy of Unix IPC Methods|author=|chapter=Chapter 7: Multiprogramming}} in ''[[The Art of Unix Programming]]''.
* {{citation |mode=cs1 |chapter-url=http://www.faqs.org/docs/artu/ch07s02.html |title=[[The Art of Unix Programming]] |first=Eric Steven |last=Raymond |chapter=Multiprogramming: Taxonomy of Unix IPC Methods: Wrappers and Bernstein Chaining}}


[[Category:Operating system technology]]
[[Category:Operating system technology]]

Latest revision as of 07:51, 2 April 2022

Chain loading is a method used by computer programs 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 overlays. 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[edit]

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[edit]

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 the process' environment variables, which are preserved across the system call.

Chain loading in Linux[edit]

In addition to the exec() process level chain loading Linux supports the kexec() system call to replace the entire operating system kernel 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[edit]

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 COM statement[1] 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[edit]

Many versions of Fortran include a CALL CHAIN or CALL LINK statement that performs chain loading, preserving the contents of COMMON storage.[2] This is not the same as the unrelated LINK subroutine in GNU Fortran.[3]

Chain loading in OS/360[edit]

OS/360 and successors 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[edit]

References[edit]

  1. ^ "HP 2000/Access BASIC" (PDF). bitsavers.trailing-edge.com. HP. pp. 11–25. Retrieved 16 January 2020.
  2. ^ IBM Corporation (1974). IBM 1130/1800 Basic FORTRAN IV Language (PDF). p. 14.
  3. ^ "The GNU Fortran Compiler". Retrieved Oct 27, 2013.