🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #126

C-code to prevent TSR from restart(if it's already active)

#126
From: Xiaojun Zhu
Date: Tue, 03 Nov 1992 22:16
37 lines
1777 bytes
Q: How to write a simple C code to detect your TSR program has already started?

In his book <<Born to code in C>, Herbert Schildt suggests using interrupt
0x64 which is unused in all DOS versions up to version 4.

The idea is as follows:

 Before you start your TSR, test 0x64:
 
   if it's already active, abort;
   otherwise, set an active flag, then start your TSR.

The book also provides the following code which I believe there is
a misprint in it. Because line 2 setvect(0x64, 1) has the wrong second
augument. (Assume that old64int has been declared correctly earlier)

..............................
line 1:   old64int=getvect(0x64);
line 2:   if(!old64int) setvect(0x64, 1); 
line 3:   else  exit(1); /* TSR has already loaded */
..............................

My questions are:
   1. How to correct the above mistake?
   2. Is it good to use this method? Why or why not?
   3. What's the alternative to do so? (Please provide simple C code!!!)
   4. Is 0x64 unused in DOS 5 as well? 
   5. Are there other unused interrupts available in ALL DOS versions? 
   6. If the answer is yes to question 5, can those interrupts be used 
      as substitutes for 0x64 for my purpose(i.e., to protect you from
      restarting your TSR.)? Why or why not?
   
Thanks for your attention!

Regards, Xiao Jun Zhu
     xjzhu@math.uwaterloo.ca
Technical Details
Message-ID: <Bx5v6x.IK3@math.uwaterloo.ca>
Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!torn!watserv2.uwaterloo.ca!watmath!xjzhu

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!utcsri!torn!watserv2.uwaterloo.ca!watmath!xjzhu
From: xjzhu@math.uwaterloo.ca (Xiaojun Zhu)
Subject: C-code to prevent TSR from restart(if it's already active)
Message-ID: <Bx5v6x.IK3@math.uwaterloo.ca>
Keywords: C-code, TSR, undocumented interrupts
Organization: University of Waterloo
Date: Tue, 3 Nov 1992 22:16:06 GMT
Lines: 37