Xref: utzoo alt.msdos.programmer:1322 comp.sys.ibm.pc.programmer:197 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!deimos!harris.cis.ksu.edu!mac From: mac@harris.cis.ksu.edu (Myron A. Calhoun) Newsgroups: alt.msdos.programmer,comp.sys.ibm.pc.programmer Subject: Re: idling in the interpreter Message-ID: <25EDB1B8.4B34@deimos.cis.ksu.edu> Date: 1 Mar 90 23:35:19 GMT References: Sender: news@deimos.cis.ksu.edu (USENET News Admin) Reply-To: mac@harris.cis.ksu.edu (Myron A. Calhoun) Distribution: usa Organization: Kansas State University, Dept of Computing & Information Sciences Lines: 60 In article pas@lcs.mit.edu (Paul A. Selkirk) writes: >Does anyone know of a bulletproof way for a TSR to tell whether DOS (assume >2.x or 3.x) is idling in the command interpreter, or executing a program? >I have determined, through much pain and disassembly, that DOS uses service >0A (buffered string input) to get the next command, but other programs use that >as well. I can get by on this knowledge, but I would prefer something a little >more certain. >For the record, I am writing a screen-saver TSR that will only trigger when DOS >is idling. There are dozens of screen-savers, but I need one that won't kill >a lengthy graphics program. (Ever try generating the Mandelbrot set on a 4.77 >MHz XT with no FPU? I thought so.) >Any leads will be duly appreciated. Quoting from chapter 16 of a preliminary version of "A Textbook on the 8086 Family" by William B. Giles, Copyright 1989, to be published by MacMillan Publishing Company in October, 1990: (I reviewed it for MacMillan and am using it in a class! Any typo's are probably mine.) "DOS keeps a one-byte flag, which is usually called the InDOS flag or the DOS Active byte. The value of this flag at any instant equals the number of calls to INT 21h functions which are currently in process of execution. In particular, if the value is zero no DOS function is presently active and so DOS functions can be safely called. Finding the value of the InDOS Flag is easy: a call to function 34h of INT 21h returns the address of the flag in es:bx." Furthermore (a paragraph or two later): "... But even when DOS is busy, it may not be executing a non- interruptible section of code; during such "safe" periods, DOS makes regular calls to INT 28H." "The sole reason for the existence of INT 21h is to provide programmers with another method of determining whether it is safe to execute DOS functions. If INT 28h is active, DOS is in a safe condition." "A number of the traditional DOS functions (01h through 0Ch) must wait for user input and, during such waiting periods, they call INT 28h repeatedly. In particular, while the DOS prompt is being displayed and DOS is calling function 01h, the INT 28h method can be used to determine when it is safe to execute DOS function calls." To actually use the above requires a "trick" almost like that of writing device drivers. When your TSR determines it needs to do something, usually it should just set an internal flag to remind itself of that fact. Then it can make periodic tests (by taking over the timer interrupt) and/or take-over INT 28h to determine when it is safe to actually do the desired work. Hope this helps. --Myron. -- #------------------------------------------------------------------------- # Myron A. Calhoun, Ph.D. E.E.; Associate Professor (913) 539-4448 home # INTERNET: mac@harris.cis.ksu.edu (129.130.10.2) 532-6350 work # UUCP: ...{rutgers, texbell}!ksuvax1!harry!mac 532-7004 fax