[comp.sys.ibm.pc] How do you do concurrency?

mike@erix.UUCP (04/01/87)

Several systems like MS-WINDOWS or GEM allow users to run several
processes concurently in MS-DOS. By this I mean allow several processes
to time share the CPU:

How is this done? I know the basic principles of time sharing operating
systems, this question really means, how is this done in MS-DOS? Are
there any available software procedures which allow one to do this
oneself? 

Mike Williams

(mike@erix.UUCP or ...mcvax!enea!erix!mike)

geller@eli.UUCP (04/03/87)

In article <1328@erix.UUCP>, mike@erix.UUCP (Mike Williams) writes:
> Several systems like MS-WINDOWS or GEM allow users to run several
> processes concurently in MS-DOS. By this I mean allow several processes
> to time share the CPU:

I can't talk for Windows but I'm pretty sure GEM is NOT multitasking.
It allows for several tasks to be resident in the system at one time
but only allows ONE to run at a time. It is more a shell and program
manager. But then again, your definition of "time share" may have
meant just what I said...

David Geller

richardg@pogo.UUCP (04/03/87)

In article <184@eli.UUCP>, geller@eli.UUCP (David Geller) writes:
>I can't talk for Windows but I'm pretty sure GEM is NOT multitasking.

This is incorrect.  GEM is multitasking.

-- 
Richard J. Greco                        "You think you've got problems, what
UUCP:  richardg@pogo.GPID.TEK.COM        are you supposed to do if you are a
Phone:  (503) 685-3860                   manically depressed robot."
Tektronix, Inc. - P.O. Box 1000 - Wilsonville, Or 97070 - Mail Stop 63/356

rps@homxc.UUCP (04/04/87)

In article <184@eli.UUCP>, geller@eli.UUCP (David Geller) writes:
> In article <1328@erix.UUCP>, mike@erix.UUCP (Mike Williams) writes:
> > Several systems like MS-WINDOWS or GEM allow users to run several
> > processes concurently in MS-DOS. By this I mean allow several processes
> > to time share the CPU:
> 
> I can't talk for Windows but I'm pretty sure GEM is NOT multitasking.
> It allows for several tasks to be resident in the system at one time
> but only allows ONE to run at a time. It is more a shell and program
> manager. 
...
> 
> David Geller

Digital Research (makers of GEM) make a product called CONCURRENT DOS
which is full blown multitasking for DOS.  It is unrelated to the GEM
product line.  However, you can have one of the tasks under CONCURRENT
DOS be a Graphics program, such as a GEM program (note, only ONE).
GEM only allows one process to be resident, open, whatever, execpt for
a print spooler which can run in the background.

CONCURRENT DOS is now available for the '386 and is supposed to be really
nice.

Russ Sharples
homxc!rps

duke@gitpyr.UUCP (04/04/87)

In article <1328@erix.UUCP>, mike@erix.UUCP (Mike Williams) writes:
> Several systems like MS-WINDOWS or GEM allow users to run several
> processes concurently in MS-DOS. By this I mean allow several processes
> to time share the CPU:
> 
> How is this done? I know the basic principles of time sharing operating
> systems, this question really means, how is this done in MS-DOS? Are
> there any available software procedures which allow one to do this
> oneself? 
> 
 
I can't speak for how Windows does multitasking, but I can describe a 
method which will work.  If you steal an interrupt, such as the timer 
interrupt, and have the interrupt vector point to some machine code you 
have written to save the contents of all registers, then you will 
successfully have saved the context of the currently running process. 
The interrupt will save the contents of the instruction pointer and 
flags on top of the current stack.  To save the contents of all 
registers, simply push them on top of the current stack.  Then you need 
only remember the stack segment (SS) and stack pointer (SP).  To 
restore the context of a process, all you need to do is load the SS 
and SP and then pop all registers off the stack in the reverse order you
pushed them, and then issue a return from interrupt.  On a timer
interrupt, you would simply swap the context of a process to 
one which is currently waiting to execute.  Obviously, this would mean 
you must initialize the stack of a process upon creation to look as 
though it has just had its context saved following an interrupt.  I'm 
not sure if I explained the process very well, but I hope you get the 
general idea.  If anything is unclear or you have any questions, I will
be more than happy to expand on anyting I have said.