[comp.lang.pascal] HAS IT BEEN DONE...

numork@ndsuvax.UUCP (James Mork) (08/17/88)

Has anyone heard of anything to do Multi-tasking in Turbo 3.0/4.0 ?
It really shouldn't be that hard to do should it?  The PC has
timer interrupts... that users can define... Has anyone out there written
anything to do multitasking in Turbo Pascal?  It would be great if 
something like this existed...
 
var s : string[20];
    d : process_type; 

begin
   if fork(d) then animateddisplay;   
   getdata(s);
   kill(d);
end;

where fork would create a child that calls animateddisplay
which would be, say, an animated display that would run concurrently
while the data was entered?  Actually a time quanta might even be
specifiable to divide the processing time unevenly...  fork(d,3)
could mean process on every 3 cycles available...

I would love to see this... I would like to write it... but I am
really unsure with how much you can mess around with the stack
and not get in trouble... Turbo 4.0 has multiple stack segments
which could really cause problems.  Couldn't Assembly routines
be written to activate a scheduler... and FORK could add to a process
queue?  The machine timer could interrupt every so often... swap the
environment and return control to the next process.  the problems
are:  WHAT, to the tee, constitutes the swap environment?  could 
a duplicate stack segment be made and the SS be changed?  this 
would use a lot of memory for each process.  If process A creates
B and then calls C wouldn't the stack look like this...
(top of stack) (activation record C) (a.r. B) (a.r. A)
now if B returns... there will be a hole in the stack (I think)
(top of stack) (activation record C) (hole) (a.r. A)
will turbo pascal put up with holes in the stack... or
will B's return blow the top of stack?

(Is this even probable at all... sigh...)  James Mork
-- 
                  UUCP                Bitnet                Internet
          uunet!ndsuvax!numork    numork@ndsuvax     numork@plains.nodak.edu