551:. However, since DOS and most DOS programs run in real mode (VCPI or DPMI makes a protected-mode program look like a real-mode program to DOS and the rest of the system by switching back and forth between the two modes), DOS TSRs and device drivers also run in real mode, and so any time one gets control, the DOS extender has to switch back to real mode until it relinquishes control, incurring a time penalty (unless they utilize techniques such as
63:
165:
22:
503:). TSRs are no exception, and take chunks from that 640 KB that are thus unavailable to other applications. This meant that writing a TSR was a challenge of achieving the smallest possible size for it, and checking it for compatibility with a lot of software products from different vendors—often a very frustrating task.
344:
handlers pointing into itself, so that it can be called again. Installing a hardware interrupt vector allows such a program to react to hardware events. Installing a software interrupt vector allows it to be called by the currently running program. Installing a timer interrupt handler allows a TSR to
426:
TSRs which will catch a specific key combination and release all TSRs loaded after them. As the chain of ISRs is singly linked, and a TSR may store the link to its predecessor anywhere it chooses, there is no general way for a TSR to remove itself from the chain. So usually a stub must be left in
518:
with different configurations for different games. In later versions of MS-DOS, "boot menu" scripts allowed various configurations to be selectable via a single menu entry. In the mid- to later 1990s, while many games were still written for DOS, the 640 KB limit was eventually overcome by
352:
The typical method of using an interrupt vector involves reading its present value (the address), storing it within the memory space of the TSR, and replacing it with an address in its own code. The stored address is called from the TSR, in effect forming a singly linked list of
462:'s limitations, TSRs have a reputation as troublemakers. Many hijack the operating system in varying documented or undocumented ways, often causing systems to crash on their activation or deactivation when used with particular applications or other TSRs.
534:
Because programming with many overlays is a challenge in and of itself, once the program was too big to fit entirely into about 512 KB, use of extended memory was almost always done using a third-party DOS extender implementing
317:. The memory and system resources used are then marked as unused. This makes it impossible to restart parts of the program without having to reload it all. However, if a program ends with the system call
447:
in a controlled manner. It is modeled after IBM's
Interrupt Sharing Protocol, originally invented for sharing hardware interrupts of an x86 processor. AMIS services are available via Int 2Dh.
332:, is called "terminate but stay resident", hence the name "TSR". Using this call, a program can make up to 64 KB of its memory resident. MS-DOS version 2.0 introduced an improved call,
476:
Cascade with other TSRs by calling the old interrupt vector. This can be done before or after they executed their actual code. This way TSRs can form a chain where each calls the next.
692:(later 64-bit versions only) all the time, disabling the ability to switch to real mode, which is needed for TSRs to function. Instead these operating systems have modern driver and
386:
and Turbo
Debugger, Quicken's QuickPay, or FunStuff Software's Personal Calendar). Parts of DOS itself use this technique, especially in DOS versions 5.0 and later. For example, the
514:
drivers—and arranging things so that there was enough free RAM to run the games, while keeping the necessary TSRs present, became very complicated. Many gamers had several
543:, because it becomes much easier and faster to access memory above the 1 MB boundary, and possible to run code in that area, when the x86 processor is switched from
450:
The proposal never gained a widespread traction among programmers in its days. It existed alongside several other competing specifications of varying sophistication.
575:
processors in the second half of the 1980s, it became possible to use memory above 640 KB to load TSRs. This required complex software solutions, named
419:
410:
Some TSRs have no way to unload themselves, so they will remain in memory until a reboot. However unloading is possible externally, using utilities like the
80:
35:
484:
and other malware, which can either take control of the PC or stay in the background. This malware can react to disk I/O or execution events by infecting
127:
439:
To manage problems with many TSRs sharing the same interrupt, a method called
Alternate Multiplex Interrupt Specification (AMIS) was proposed by
99:
819:
519:
putting parts of the game's data above the first 1 MB of memory and using the code below 640 KB to access the extended memory using
415:
106:
627:
which try to maximize the available space in the first 640 KB by determining how best to allocate TSRs between low and high memory.
428:
596:
411:
113:
41:
95:
645:) which bypassed the 640 KB barrier, many of the issues relating to TSRs disappeared, and with the widespread adoption of
769:
704:, allowing multiple programs and device drivers to run simultaneously without the need for special programming tricks; the
921:
669:
does not allow a computer to boot into a DOS Kernel by shutting down
Windows Me; thus TSRs became useless on Windows Me.
657:) – which rendered most TSRs unnecessary and some TSRs incompatible – the TSR faded into obsolescence, though
427:
memory when unloading a TSR, causing memory fragmentation. This problem gave rise to TSR cooperation frameworks such as
465:
By chaining the interrupt vectors TSRs can take complete control of the computer. A TSR can have one of two behaviors:
536:
390:
command-line editor and various other utilities are installed by running them at the command line (manually, or from
263:
so it can be reactivated later. This technique partially overcame DOS's limitation of executing only one program, or
226:
208:
146:
49:
190:
867:
842:
556:
120:
959:
510:
on the PC platform pushed up against this limit and left less and less space for TSRs—even essential ones like
395:
175:
84:
794:
531:
and run the program in protected mode. The latter allowed to have code and data in the extended memory area.
403:
182:
540:
728:
552:
346:
662:
588:
897:
739:
705:
469:
Take complete control of an interrupt by not calling other TSRs that had previously altered the same
278:
that a computer user might call up several times a day, while working in another program, by using a
823:
623:. Later, memory managers started including programs such as Quarterdeck's Optimize or Microsoft's
954:
701:
443:
as an improvement over previously used services offered via INT 2Fh. AMIS provides ways to share
306:
can run only one program at a time. When a program finishes, it returns control to DOS using the
186:
73:
641:
470:
524:
444:
527:
technique. An alternative later approach was to switch the CPU into
Protected Mode by using
492:
708:
and its modules have been made exclusively responsible for modifying the interrupt table.
374:
TSRs can be loaded at any time; either during the DOS startup sequence (for example, from
8:
891:
500:
734:
717:
938:
932:
941:– a function library to write self-highloading, removable TSRs in assembler (zipfile)
788:
697:
646:
616:
354:
291:
279:
268:
383:
283:
275:
264:
248:
745:
693:
568:
520:
260:
723:
685:
580:
548:
481:
336:('Keep Process'), which removed this limitation and let the program return an
325:, the operating system does not reuse a certain specified part of its memory.
948:
807:
491:
Additionally, in DOS all programs, even those with large amounts of physical
440:
287:
907:
765:
677:
636:
528:
391:
375:
863:
615:. The memory areas usable for loading TSRs above 640 KB are called "
572:
488:(.EXE or .COM) files when it is run and data files when they are opened.
337:
307:
256:
838:
681:
673:
666:
654:
650:
507:
485:
689:
612:
544:
515:
341:
193:. Statements consisting only of original research should be removed.
62:
902:
624:
496:
259:
to return control to DOS as though it has finished, but remains in
340:. Before making this call, the program can install one or several
379:
367:
314:
925:
608:
604:
592:
511:
387:
286:
was an early and popular example of this type. Others serve as
658:
898:
How can I write a TSR (Terminate-and-Stay-Resident) utility?
600:
584:
480:
The terminate-and-stay-resident method is used by most DOS
661:
applications can do TSR-like tricks such as patching the
459:
303:
252:
361:, or ISRs. This procedure of installing ISRs is called
401:) rather than loading them as device drivers through
294:
that the operating system does not directly support.
905:; a free book on DOS programming in C; Chapter 27 –
87:. Unsourced material may be challenged and removed.
776:. Archived from the original on September 28, 2009
619:" (UMBs) and loading programs into them is called
458:While very useful, or even essential to overcome
946:
684:, and later) replaced DOS completely and run in
267:, at a time. TSRs are used only in DOS, not in
809:HelpPC reference: INT 21,0 – Program Terminate
933:Alternate Multiplex Interrupt Specification
50:Learn how and when to remove these messages
378:), or at the user's request (for example,
495:, must be loaded into the first 640
227:Learn how and when to remove this message
209:Learn how and when to remove this message
147:Learn how and when to remove this message
506:In the late 1980s and early 1990s, many
764:
947:
371:an interrupt or an interrupt vector.
96:"Terminate-and-stay-resident program"
635:With the development of games using
434:
158:
85:adding citations to reliable sources
56:
15:
241:terminate-and-stay-resident program
13:
665:(IDT) because Windows allowed it.
14:
971:
885:
31:This article has multiple issues.
922:IBM's Interrupt-Sharing Protocol
163:
61:
20:
896:comp.os.msdos.programmer FAQ –
870:from the original on 2016-06-19
845:from the original on 2017-12-01
770:"Beat the Bug—Computer Viruses"
72:needs additional citations for
39:or discuss these issues on the
856:
831:
812:
801:
758:
1:
751:
924:, zip archive, 6.5 KB (
7:
729:DOS Protected Mode Services
711:
579:. Some memory managers are
347:programmable interval timer
189:the claims made and adding
10:
976:
663:interrupt descriptor table
630:
407:statements in CONFIG.SYS.
359:interrupt service routines
345:run periodically (using a
828:also known as frameworks.
820:"a list of TSR libraries"
793:: CS1 maint: unfit URL (
740:Resident System Extension
571:boards and especially of
562:
453:
577:expanded memory managers
935:(AMIS), v.3.5 (zipfile)
702:preemptive multitasking
523:(EMS) by making use of
639:(an early example was
399:from within CONFIG.SYS
297:
960:DOS memory management
567:With the arrival of
81:improve this article
617:upper memory blocks
501:conventional memory
445:software interrupts
420:TurboPower Software
328:The original call,
735:Extension (Mac OS)
676:series (including
355:interrupt handlers
174:possibly contains
908:"TSR programming"
698:memory protection
647:Microsoft Windows
435:Interrupt sharing
237:
236:
229:
219:
218:
211:
176:original research
157:
156:
149:
131:
54:
967:
918:
914:
912:
879:
878:
876:
875:
860:
854:
853:
851:
850:
835:
829:
827:
822:. Archived from
816:
810:
805:
799:
798:
792:
784:
782:
781:
762:
696:frameworks with
471:interrupt vector
406:
398:
335:
331:
324:
320:
312:
284:Borland Sidekick
276:utility software
249:computer program
232:
225:
214:
207:
203:
200:
194:
191:inline citations
167:
166:
159:
152:
145:
141:
138:
132:
130:
89:
65:
57:
46:
24:
23:
16:
975:
974:
970:
969:
968:
966:
965:
964:
945:
944:
916:
910:
906:
888:
883:
882:
873:
871:
864:"TSR Libraries"
862:
861:
857:
848:
846:
837:
836:
832:
818:
817:
813:
806:
802:
786:
785:
779:
777:
763:
759:
754:
746:Windows service
714:
649:and especially
633:
569:expanded memory
565:
521:expanded memory
456:
437:
402:
396:
333:
329:
322:
318:
310:
300:
261:computer memory
233:
222:
221:
220:
215:
204:
198:
195:
180:
168:
164:
153:
142:
136:
133:
90:
88:
78:
66:
25:
21:
12:
11:
5:
973:
963:
962:
957:
955:DOS technology
943:
942:
936:
929:
919:
900:
894:
887:
886:External links
884:
881:
880:
866:. 2016-06-19.
855:
830:
826:on 2007-08-17.
811:
800:
756:
755:
753:
750:
749:
748:
743:
737:
732:
726:
724:Desk accessory
721:
713:
710:
686:protected mode
632:
629:
564:
561:
549:protected mode
478:
477:
474:
455:
452:
436:
433:
357:, also called
299:
296:
288:device drivers
274:Some TSRs are
251:running under
235:
234:
217:
216:
171:
169:
162:
155:
154:
69:
67:
60:
55:
29:
28:
26:
19:
9:
6:
4:
3:
2:
972:
961:
958:
956:
953:
952:
950:
940:
937:
934:
930:
927:
923:
920:
909:
904:
901:
899:
895:
893:
890:
889:
869:
865:
859:
844:
840:
834:
825:
821:
815:
808:
804:
796:
790:
775:
771:
767:
766:Maybury, Rick
761:
757:
747:
744:
741:
738:
736:
733:
730:
727:
725:
722:
719:
716:
715:
709:
707:
703:
699:
695:
691:
687:
683:
679:
675:
670:
668:
664:
660:
656:
653:(followed by
652:
648:
644:
643:
638:
637:DOS extenders
628:
626:
622:
618:
614:
610:
606:
602:
598:
594:
590:
586:
582:
578:
574:
570:
560:
558:
554:
550:
546:
542:
538:
532:
530:
529:DOS extenders
526:
522:
517:
513:
509:
504:
502:
498:
494:
489:
487:
483:
475:
472:
468:
467:
466:
463:
461:
451:
448:
446:
442:
441:Ralf D. Brown
432:
430:
425:
421:
417:
413:
408:
405:
400:
393:
389:
385:
381:
377:
372:
370:
369:
364:
360:
356:
350:
348:
343:
339:
326:
316:
309:
305:
295:
293:
289:
285:
281:
277:
272:
270:
266:
262:
258:
254:
250:
246:
242:
231:
228:
213:
210:
202:
192:
188:
184:
178:
177:
172:This article
170:
161:
160:
151:
148:
140:
129:
126:
122:
119:
115:
112:
108:
105:
101:
98: –
97:
93:
92:Find sources:
86:
82:
76:
75:
70:This article
68:
64:
59:
58:
53:
51:
44:
43:
38:
37:
32:
27:
18:
17:
917:(80 KB)
892:An early TSR
872:. Retrieved
858:
847:. Retrieved
833:
824:the original
814:
803:
778:. Retrieved
773:
760:
742:/ RSX (CP/M)
678:Windows 2000
671:
640:
634:
621:loading high
620:
607:, and later
576:
566:
533:
505:
499:of RAM (the
490:
479:
464:
457:
449:
438:
423:
409:
392:AUTOEXEC.BAT
376:AUTOEXEC.BAT
373:
366:
362:
358:
351:
327:
301:
273:
255:that uses a
244:
240:
238:
223:
205:
196:
173:
143:
137:October 2009
134:
124:
117:
110:
103:
91:
79:Please help
74:verification
71:
47:
40:
34:
33:Please help
30:
903:A to Z of C
774:PC Top Tips
589:Quarterdeck
573:Intel 80386
508:video games
424:soft reboot
416:RELEASE.EXE
394:or through
334:INT 21h/31h
323:INT 21h/31h
311:INT 21h/4Ch
308:system call
257:system call
949:Categories
874:2019-11-14
849:2019-11-14
780:2012-02-09
752:References
682:Windows XP
674:Windows NT
667:Windows Me
655:Windows 98
651:Windows 95
516:boot disks
486:executable
431:and AMIS.
243:(commonly
183:improve it
107:newspapers
36:improve it
690:long mode
613:Microsoft
545:real mode
429:TesSeRact
418:combo by
342:interrupt
338:exit code
302:Normally
199:June 2024
187:verifying
42:talk page
868:Archived
843:Archived
839:"int 2D"
789:cite web
768:(1998).
712:See also
625:MEMMAKER
597:Qualitas
557:CLOAKING
412:MARK.EXE
384:Sidekick
363:chaining
292:hardware
939:AMISLIB
694:service
631:Decline
525:overlay
482:viruses
397:INSTALL
380:Borland
368:hooking
330:INT 27h
319:INT 27h
315:DOS API
313:of the
269:Windows
247:) is a
181:Please
121:scholar
926:Simtel
915:
731:/ DPMS
720:(Unix)
718:Daemon
706:kernel
609:EMM386
605:Compaq
563:Return
512:CD-ROM
454:Faults
404:DEVICE
388:DOSKEY
280:hotkey
123:
116:
109:
102:
94:
911:(PDF)
659:Win16
128:JSTOR
114:books
931:The
795:link
700:and
672:The
642:Doom
601:CEMM
585:QEMM
583:and
581:QRAM
553:DPMS
541:DPMI
537:VCPI
298:Use
290:for
265:task
100:news
688:or
611:by
603:by
595:by
593:386
587:by
559:).
555:or
547:to
539:or
493:RAM
460:DOS
422:or
382:'s
365:or
349:).
321:or
304:DOS
253:DOS
245:TSR
185:by
83:by
951::
841:.
791:}}
787:{{
772:.
680:,
599:,
591:,
497:KB
282:.
271:.
239:A
45:.
928:)
913:.
877:.
852:.
797:)
783:.
473:.
414:/
230:)
224:(
212:)
206:(
201:)
197:(
179:.
150:)
144:(
139:)
135:(
125:·
118:·
111:·
104:·
77:.
52:)
48:(
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.