Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site bnrmtv.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!sun!amdahl!bnrmtv!connery From: connery@bnrmtv.UUCP (Glenn Connery) Newsgroups: net.micro.pc Subject: Re: DOS re-entrancy Message-ID: <277@bnrmtv.UUCP> Date: Tue, 11-Mar-86 15:13:13 EST Article-I.D.: bnrmtv.277 Posted: Tue Mar 11 15:13:13 1986 Date-Received: Fri, 14-Mar-86 06:25:25 EST References: <103@nvuxr.UUCP> <23900011@siemens.UUCP> Organization: Bell Northern Research, Mtn. View, CA Lines: 53 > > There is a flag buried in the internal data area for MS-DOS called INDOS. > A 0 value indicates that MS-DOS is not currently executing in a critical > section. Any other value indicates that you can not make a Int 21 call. > > To find out the current value of this flag: > > 1. Before interrupt processing starts execute the GET_INDOS_FLAG > function. This is function 34h in MS-DOS. > (i.e. AX = 34h when doing the Int 21) > > 2. Upon return you don't get the flag but rather a pointer to > it in ES:BX. ES = the segment address and BX = the offset > address of the INDOS flag. > > 3. When the interrupt occurs directly test this byte from the > interrupt handler to determine if calls to MS-DOS are > allowable. You will have to determine appropriate actions > if the interrupt occurred during a critical section of MS-DOS. > > Hope this helps. > > Jim Vallino > {allegra,ihnp4}!princeton!siemens!jrv While this is accurate, it is only partially accurate. Check out page 252 of PC Magazine October 15, 1985 for the gory details. Basically DOS switches to an internal stack which is where the re-entrancy problem comes in. There are actually three different stacks... one for 01H to 0CH, one for 0DH and above, and one for 01H through 0CH when a Critical Error is in progress. The DOS Print command uses the INDOS flag to tell whether it can do anything with DOS file calls or not. The problem is that on the DOS command level we are in function 0AH waiting for keyboard input ALL THE TIME! So, PRINT takes advantage of yet another undocumented feature of DOS... INT 28H which DOS executes whenever it is in a wait state (like during keyboard input) during function calls 01H to 0CH. Thus when INT 28H is invoked, PRINT knows that a function call of 01H to 0CH is in progress and because a separate stack is used for 01H to 0CH and the file access calls... well you get the idea. This should not be necessary if you don't need to work through DOS keyboard input calls. If you do, you'll have to install yourself in the chain for INT 28H just like PRINT or you won't execute a whole lot (like never). Of course with all of this undocumented and reasonably kludgey, it is absolutely guaranteed to change the next DOS rev, so take your chances... ...Glenn -- Glenn Connery, Bell Northern Research, Mountain View, CA {hplabs,amdahl,3comvax}!bnrmtv!connery