[comp.sys.ibm.pc] Dos/TSR/Multitasking interaction

phil@umd5.umd.edu (Philip Shafer) (03/04/88)

DOS/TSR/Multitasking interaction

    I have a problem with DOS. Who doesn't?

    I have just written a background tasker for the IBM-PC.  It is part
of work done at the University of Maryland under contract to IBM.  I
have a few questions which I'm hoping that someone can help me with. 
Let me describe my program. 

    The tasker maintains tasks in a ring, scheduled round-robin.  Tasks
are forked and killed from this ring.  Tasks make explicit calls to the
tasker to yield the CPU to the next task, but the tasker realizes that
the foreground DOS application will not be kind enough to yield. 
Therefore it must preempt the foreground task and steal the CPU away
from it. 

    Initially the only task is the foreground DOS shell.  The tasker
grabs some interrupts, TSRs itself, and begins stealing cycles from the
foreground task.  Driven by the timer IRQ, the tasker jumps in and
checks to see if it is 'safe' to force a yield of the CPU.  'Safe' is
defined as follows: we are safe if we are not inside a dangerous
interrupt, or if we are inside an explicitly safe one.  My list of
dangerous interrupts are: Disk/diskette (13h), System services (15h),
Printer (17h), Critical error (24h), PCLan hook (2Ah), and PC
ASI/Netbios (5Ch).  My list of explicitly safe interrupts are: Keyboard
(16h) and Video (10h).  So, if a timer interrupt happens are the PC is
in INT 13h, the tasker will leave things alone.  If, however, the PC is
in INT 10h, even if it got there through INT 24h, the tasker will yield
the CPU to the next task.  Note that there is a user configurable
quantum which represents the minimum number of ticks which the
foreground task will get before background intervention. 

    My questions deal with the DOS interface.  I was listing Dos
services (21h) as one of my dangerous interrupts, but found a great deal
of trouble dealing with DOS as a simple interrupt.  A user program can
do a gets() (INT 21h func 0Ah), have the user type '^C', have DOS do a
CtrlBreak (INT 23h), and go on performing everyday life-type activities
(ie.  longjmp() to the top of a loop).  This example is annoying but
solvable.  The one the I'm having trouble with is user programs that
exec other programs, as I have no way (that I know of) to determine when
DOS stops being DOS and starts being the exec'ed program.  I sure there
are dozens of other twisted, tainted, horrid beyond belief cases that I
have not yet begun to think of (please let me know of any). 

    Which brings me (finally) to my real question: What kinds of
problems am I in for if I don't trap INT 21h?? Since my tasks are
TSR-based, and realize that they cannot use DOS, BIOS, or any common
other resource, the only type of problems that I really need to avoid
are timing-dependant ones.  Are there any others??

    I'd appreciate any help I can get. Thanks,
        phil

#   phil@umd5.umd.edu       # University of Maryland, College Park
#   shafer@umdd.bitnet      # IBM@UOM, Pc/Ip project
#   I tried to make a signature, but the disk was spinning
#   so fast I could hardly write (my pencil kept breaking)

mru@unccvax.UUCP (markus ruppel) (03/06/88)

in article <2418@umd5.umd.edu>, phil@umd5.umd.edu (Philip Shafer) says:
> Keywords: DOS TSR tasking background
> 
> DOS/TSR/Multitasking interaction
> 
>     I have a problem with DOS. Who doesn't?
  
Right, everybody has, mainly because DOS IS NOT DESIGNED TO MULTI-
TASK !!!!! Why don't you switch to a real multitasking and multi-
user system like Concurrent DOS made by Digital Research, Inc. ?
It provides you with BUILD IN system calls to disconnect ( detattch )
a program ( task ) from its console ( screen, you have four virtual
consoles on your main screen ) , to run in the background, to  com-
municate between background tasks ( queues ) and so on. 

The most inportant point is that it has been available for the last
3 years as an OS and became pretty much mature by now. It's so called
native mode is CP/M, but it supports  DOS 3.3 calls as well. That    
means you can run DOS AND CP/M applications.  I've been designing 
a multitasking ( 8 background tasks and one foreground user inter-
face ) device control and data aquisition  system in our labs and
it works great. The code is written in MS C 5.0 and I've built my
own little library of Concurrent DOS system calls to manage the 
task spawning and queue management. 
With CDOS you won't have to worry about 'good and bad' int's,
because the system is reentrant. 

( rest deleted )

> #   phil@umd5.umd.edu       # University of Maryland, College Park
> #   shafer@umdd.bitnet      # IBM@UOM, Pc/Ip project
> #   I tried to make a signature, but the disk was spinning
> #   so fast I could hardly write (my pencil kept breaking)



If you have any further questions, let me know.
Markus

Disclaimer: Neither do I own stocks nor am I affiliated in any 
            way to DRI, except as being a satisfied customer.

nathan@eddie.MIT.EDU (Nathan Glasser) (03/09/88)

In article <920@unccvax.UUCP> mru@unccvax.UUCP (markus ruppel) writes:
>Right, everybody has, mainly because DOS IS NOT DESIGNED TO MULTI-
>TASK !!!!! Why don't you switch to a real multitasking and multi-
>user system like Concurrent DOS made by Digital Research, Inc. ?

I'm not the original poster, but I think I may have a good answer for
you. When a company makes a product for others to use, they'd like
not to require the user to by another piece of software he wouldn't
otherwise want. In this case, the user's already got MS-DOS, and
so the developer develops his product for DOS, and doesn't require
the user to buy and install Concurrent Dos or some other system.
-- 
				Nathan Glasser
fnord				nathan@{mit-eddie.uucp, xx.lcs.mit.edu}
"A tribble is the only love that money can buy."	    
Presently there is insufficient evidence to conclude that tribbles spread AIDS.

mru@unccvax.UUCP (Markus Ruppel) (03/20/88)

in article <8424@eddie.MIT.EDU>, nathan@eddie.MIT.EDU (Nathan Glasser) says:
| 
| In article <920@unccvax.UUCP> I write: writes:
||Right, everybody has, mainly because DOS IS NOT DESIGNED TO MULTI-
||TASK !!!!! Why don't you switch to a real multitasking and multi-
||user system like Concurrent DOS made by Digital Research, Inc. ?
| 
| I'm not the original poster, but I think I may have a good answer for
| you. When a company makes a product for others to use, they'd like
| not to require the user to by another piece of software he wouldn't
| otherwise want. In this case, the user's already got MS-DOS, and
| so the developer develops his product for DOS, and doesn't require
| the user to buy and install Concurrent Dos or some other system.
| -- 
| 				Nathan Glasser
| fnord				nathan@{mit-eddie.uucp, xx.lcs.mit.edu}

But that always depends on the amount of trouble you have to go through 
to get software to do what it was not designed to do.
I prefer to cut my development time which is more valuable than the cost
of for example Concurrent DOS ( or an equivalent ( is there any ??? :-))
system ).

Markus Ruppel l

UUCP: ...mcnc!unccvax!mru
BITNET: acc00mr1@unccvm 
m