Terminate and stay resident program

The abbreviation TSR comes from the DOS environment and stands for " Terminate and Stay Resident ". This concept was developed as a precursor to subsequent multi-tasking, so that certain tasks ( clock, drivers, system services) can run permanently as a background process, or simply to extend functionality of the operating system or replace.

Development concepts for background processes

Possible and effective, this was the late 1970s, mainly through the development of powerful 16- bit processors and the interrupt architecture, with the help of a variety of devices of a computer in a regular clock can be addressed by the operating system relatively independent. Since communication between these devices and the processor is not without appropriate " management programs " ( device drivers) can be so offered a new possibility, even independent of hardware components to write programs that remain in memory and are called by the interrupt again in the background.

Precursor for home computers

Imperative is not the interrupt controller. Previously, most operating systems were on 8- bit processors such as the Zilog Z80 with modular processes eg equipped for the storage and image management. Since these are processed through a jump addresses in a regular rhythm, offer themselves for further applications basically two ways to participate in this concept (simplified description):

  • For operating systems with modifiable jump addresses in RAM (then not a given yet) direct resident programs this to base yourself, and only then, the jump to system process whose address is known from the jump address stored in RAM before redirecting that resident, the program remembers. So you switch between an application program and the System process.
  • The same option can also be used in some home computers, the entire operating system, as it was then housed quite common in the read only memory ( ROM) (just as today, the firmware of the system). If the operating system at startup jump variables writes to the RAM memory, this can jump addresses can be changed as described above.
  • If this jump addresses are called directly from the ROM, the application at startup must completely replace the actual operating system and access the system-relevant background processes in the ROM itself in order to keep yourself and the system viable. An illustrative example is a stopwatch in the chess program of the Sinclair ZX- Spectrum. If the player during a train stops the assembler part to cache the score under a Basic program, the interpreter regularly returns control to the chess clock, which will continue thus.

The TSR programs under DOS

A TSR is loaded and, for the time being like any normal program, executed. Normally, a DOS program terminates by calling the DOS operating system function 20h (part of the software interrupt 21h) interrupt 21h, function 4Ch or just interrupt. DOS are then free the memory used by the program, and other resources. TSR programs in the "normal " (transient ) execution part likewise completed in the memory ( sometimes even of the released memory ), but for this purpose another DOS function is called; this is either 31h or 27h interrupt interrupt 21h, function. The "special" (resident ) TSR part, a small control center, then continue to remain active in memory to be called again.

In order for this TSR service may remain active, result is the so -called Interruptverbiegung. This is from the interrupt vector table of the system (for DOS -based computers always in the first KB of memory ), the jump address concern to the original code, stored in the new interrupt vector, and rewritten at the end of the table entry of the interrupt to its own vector. When calling the interrupt (possibly a software interrupt ) is read to the remaining part of the resident TSR and run this from the interrupt vector table address. Depending on the type of TSRs ( and, for software interrupts, depending on the called function ) can then also run the previous interrupt the resident portion.

A very popular example is the timer interrupt (interrupt 1Ch timer ) for a resident clock. This is almost exactly as described above for home computer, but hardware controlled by means of interrupts and thus independent of software weaknesses. This TSR programs run much more stable. The DOS probably the most " bent " software interrupt is the DOS function interrupt (interrupt 21h DOS), which contains most of the functions of the operating system DOS for other programs. TSR programs can, for example, monitor specific functions, record, prohibit or even in the loaded DOS actually not add existing functions.

Device drivers are a further example of application for TSR programs. Simple examples are DOS mouse driver ( hardware interrupt 14h - Serial interface, as well as software interrupt 33h - mouse functions for DOS programs ), as well as keyboard and EGA driver, drivers for the expansion memory, etc. When setting up a computer you should because the particular behavior of TSR programs that can only be loaded into conventional memory, never load more TSR programs from minor because the gaps left their transient parts, may be filled by the smaller TSR programs - conversely, it is possible that the larger will not fit in the memory, because the "gaps " which are no longer sufficient, the transient parts of the smaller left for the larger ones. Some TSRs prevent the formation of memory gaps. Well by skillfully moving the interrupt vectors to be installed

A widely used tool that worked on the TSR principle, Sidekick was, with which it was possible to make prints in landscape orientation on the paper, even if neither the respective application program or printer driver to be offered this option.

765648
de