Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sol.ctr.columbia.edu!bronze!yawei From: yawei@bronze.ucs.indiana.edu (mr. yawei) Newsgroups: comp.os.msdos.programmer Subject: Re: TSR PROGRAMMING PROBLEM Message-ID: <1991Jan30.050646.7067@bronze.ucs.indiana.edu> Date: 30 Jan 91 05:06:46 GMT References: <1991Jan29.173752.10045@bronze.ucs.indiana.edu> <5369@trantor.harris-atd.com> <2168@njitgw.njit.edu> Organization: Indiana University, Bloomington Lines: 32 In article <2168@njitgw.njit.edu> cd5340@mars.njit.edu (Charlap) writes: >>>This is called the DOS re-entrancy problem which anyone who is teaching >>>you to write TSRs should have told you about. Simply speaking, DOS >>>cannot be entered twice. > >Not quite. DOS re-enters itself all over the place. There is a scheduler >interrupt (I forget what it is, though) which is very undocumented, which >many hackers use for making re-entrant TSR's. Most notable of these is the >DOS PRINT command, which uses the scheduler interrupt in order to do background >printing. You didn't read the rest of my paragraph. :-) It said "actual situation is more complicated as DOS uses several stacks..." To be exact (and make my ends covered), DOS uses 3 stacks for its various function calls. So if you stretch it, you can re-enter DOS for a miximum of 3 times. A few other glitches (restrictions) reduce the maximum to 2 times. DOS itself does not detect that you are trying to trash its stack, so it takes elaborate programming to ensure that the re-entrancies are safe. I am not going to elaborate how to do this as it probably will take a couple of chapters. :-) The interrupt you just mentioned is int 28h. Within interrupt 28h it is safe to access some of the DOS functions which mainly deal with disk i/o etc. If you set the DOS critical error flag you can access all the DOS functions within int 28h. The problem in the original question was DOS re-entrancy, however. yawei