0% found this document useful (0 votes)
503 views23 pages

Terminate and Stay Resident

Terminate and Stay Resident (TSR) programs allow software to remain loaded in memory even after execution terminates, making them quickly accessible. TSRs terminate normally but reserve memory, overlaying other programs. They are activated by keyboard shortcuts. TSRs have initialization, data, and resident sections. The initialization gets and sets interrupt vectors, reserves memory. The resident section preserves registers, executes tasks, and restores original interrupt handling. TSRs are uninstalled by restoring original interrupt addresses and freeing memory.

Uploaded by

shikhamailme84
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
503 views23 pages

Terminate and Stay Resident

Terminate and Stay Resident (TSR) programs allow software to remain loaded in memory even after execution terminates, making them quickly accessible. TSRs terminate normally but reserve memory, overlaying other programs. They are activated by keyboard shortcuts. TSRs have initialization, data, and resident sections. The initialization gets and sets interrupt vectors, reserves memory. The resident section preserves registers, executes tasks, and restores original interrupt handling. TSRs are uninstalled by restoring original interrupt addresses and freeing memory.

Uploaded by

shikhamailme84
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

Terminate and Stay Resident

(TSR)
Terminate and Stay Resident
• Terminate execution of the currently executing program , passing a
return code to the parent process, but reserves part or all of the
program’s memory so that it will not be overlaid by the next transient
program to be loaded.
• A terminate and stay resident (TSR) program is one that is set up to
be loaded and then remain in computer memory so that it is quickly
accessible when a user presses a certain keyboard combination.
MS-DOS Program
• Programs that run under MS-DOS comes into two basic flavours.
1. .COM Programs
2. .EXE Programs
Transient Program
These programs also referred as transient programs (Short term,
Temporary)
• Transient program “Owns” the memory block it has never been
allocated and has nearly total control of the system’s resources while
executing.
• When program terminates either because of aborted by the OS or
completed work and systematically performed final exit back to MS-
DOS , then the memory block is freed (so called as transient) and can
be used by the next program .
Resident Program
• Programs are reside on memory while other programs are running
and we can activate their service through special keystroke.
• We can load the resident programs after DOS is loaded and before
activating other normal processing programs .
• They are almost always .COM programs and are also known as
Terminate and Stay Resident (TSR) Programs.
TSR Programs
• These programs start when you first turn on your computer and stay in the
memory. Ready for use, even if they are not active on your screen.
• They appear to exit, but remain in the memory to perform tasks in the
background.
• TSR programs typically include Clock, Screen Savers, Calculators.
• When running another program in DOS you can press the preset keyboard
key or combination of keys and the TSR programs will “POP-UP” into view.
• Most of TSR programs did not have option for unloading themselves from
memory, so loading TSR meant it would stay until a reboot.
TSR
• Abbreviation of terminate and stay resident. Refers to DOS
programs that can be memory resident (remaining in memory at all
times once they are loaded). Calendars, calculators, spell checkers,
thesauruses, and notepads are often set up as TSRs so that you can
instantly access them from within another program. TSRs are
sometimes called pop-up programs because they can pop up
in applications.
TSR
• When you install a TSR, you define a special key sequence (usually
a control character) that will invoke the TSR program. You can then
press this hot key from within any application to run the TSR program.
Many programs can be installed as a TSR, but TSRs reduce the
amount of memory available to other programs. In addition, not all
TSRs interact well with each other. You may have difficulties,
therefore, if you try to keep too many TSRs in main memoryat once.
• TSRs are unnecessary with multitasking operating systems such
as Windows, OS/2, and the Mac OS.
interrupt vector table IVT
• An "interrupt vector table" (IVT) is a data structure that associates a
list of interrupt handlers with a list of interrupt requests in a table of
interrupt vectors. Each entry of the interrupt vector table, called an
interrupt vector, is the address of an interrupt handler.
Interrupt Vector Table
Interrupt vector
• An interrupt vector is the memory location of an interrupt handler,
which prioritizes interrupts and saves them in a queue if more than
one interrupt is waiting to be handled.
• An interrupt is a signal from a device attached to a computer, or from
a program within the computer, that tells the OS (operating system)
to stop and decide what to do next.
• When an interrupt is generated, the OS saves its execution state by
means of a context switch, a procedure that a
computer processor follows to change from one task to another while
ensuring that the tasks do not conflict. Once the OS has saved the
execution state, it starts to execute the interrupt handler at the
interrupt vector.
Interrupts Service Routine (ISR) Interrupt Handler
• An ISR (also called an interrupt handler) is a softwareprocess invoked by an
interrupt request from a hardware device. It handles the request and sends it to
the CPU, interrupting the active process. When the ISR is complete, the process is
resumed.
• A basic example of an ISR is a routine that handles keyboard events, such as
pressing or releasing a key. Each time a key is pressed, the ISR processes
the input. For example, if you press and hold the right arrow key in a text file, the
ISR will signal to the CPU that the right arrow key is depressed. The CPU sends
this information to the active word processor or text editing program, which will
move the cursor to the right. When you let go of the key, the ISR handles the "key
up" event. This interrupts the previous "key down" state, which signals to the
program to stop moving the cursor.
Structure of TSR
• TSR Program is divided into Three sections.
1. Initialization Routine
2. Data Area
3. Resident Routine
Initialization Routine
• Steps to be performed in the initialization routine
1. Get Interrupt Vector
2. Set Interrupt Vector
3. Terminate and stay Resident
Values of Interrupt
Timer Interrupt (INT 08H)
Keyboard Interrupt (INT 09H)
INT 21H Functions
• Int 21H Function 35H (53) (MS-DOS Page No. 393)
Get Interrupt vector
• Obtains the address of the current interrupt –handler routine for the
specified machine interrupt
• CALL With
AH = 35H
AL= Interrupt Number
• Returns
• ES: BX = Segment : Offset of interrupt handler

• Al,08H-Get interrupt vector for timer interrupt


INT 21H Functions
• Int 21H Function 25H (37) (MS-DOS Page No. 377)
Set Interrupt vector
• Initialize a CPU interrupt vector to point to an interrupt handling routine
• CALL With
AH = 25H
AL = Interrupt Number
DS: DX = Segment : Offset of Interrupt Handling Routine
• Returns
Nothing
INT 21H Functions
• Int 21H Function 31H (49) (MS-DOS Page No. 390)
Terminate and Stay Resident
• Terminate execution of the currently executing program , passing a return
code to the parent process, but reserves part or all of the program’s
memory so that it will not be overlaid by the next transient program to be
loaded.
• CALL With:
AH = 31H
AL = return code
DX = Amount of memory to reserve (in paragraph)
Returns: Nothing
INT 1Ah, 02h
Read Real-Time Clock Time
• INT 1Ah, 02h Read Real-Time Clock Time
• Reads the time from the computer's real-time clock.
• On entry: AH 02h
• Returns: CF Set if clock not operating; else cleared
• CH Hours (BCD)
• CL Minutes (BCD)
• DH Seconds (BCD)
• DL 1 if daylight saving time option; else 0
Data Area
• We know that before replacing the entry in interrupt vector table, we
have stored the original address. To store this 32 bit address (16 bit
segment + 16 bit offset) we have reserve 32 bit space in the data
area.
• The data area may include additional data definitions as per program
requirements.
Resident Routine
• Whenever the TSR is activated by any of the interrupt, the program control
is first transferred to the resident program and after execution of resident
program, the program control is transferred to the original ISR of the
requested interrupt.
• In this process, the resident program uses CPU registers and may change
their contents, which is not desired and execution of ISR may give wrong
results because of changed contents of registers.
• Therefore it is necessary to preserve the contents of registers. To execute
desired task.
• Restore original contents of CPU registers .
• Finally resident program should have unconditional jump instruction with
the address of original interrupt service routine.
Uninstalling of TSR
• To uninstall TSR we have to perform two things
1. Restore the original addresses of the interrupts.
2. Release the memory block which has the current program by using
Function 49H of INT 21H (MS-DOS Page No. 439)
3. Free Allocated Memory

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy