Mail Archives: djgpp/2001/07/28/03:58:27
> From: "Rafal Maj (Raf256)" <raf256 AT go2 DOT pl>
> Newsgroups: comp.os.msdos.djgpp
> Date: Sat, 28 Jul 2001 07:05:18 +0200
>
> Is there some possibility in DJGPP to run Dos program (16-bit, or 32-bit
> make by DJGPP) and to continue in some way execution of main program in
> background while spawned program is still running ?
Not easily. The problem is that the DPMI spec explicitly prohibits
switching stacks inside a hardware interrupt handler, so you cannot
write a scheduler which switches tasks inside the timer tick interrupt
handler.
This issue was discussed several times, and the available paths to
pull that trick are:
- work around the DPMI limitation by writing code that exploits fine
details of one specific DPMI server (probably CWSDPMI, since we
have the sources);
- limit the solution to Windows: then you could run the other
program in a separate DOS box, and Windows handles the
multitasking for you. The problem with this is that you cannot
redirect standard streams of the child program in a normal way,
and passing arguments and inheriting the environment variables is
tricky;
- multi-task not on timer ticks, but on system calls, like input or
output from/to the screen. You could, for example, hook Int 31h,
filter calls to Int 21h functions that do screen I/O, and switch
between the two threads when that happens. This is suitable for
applications where a child program is invoked to be fed some
input, and the resulting output should go back to the parent; an
example is Emacs which invokes GDB as part of its debugging
interface. This solution is limited to DJGPP programs.
Neither of these is simple, and there are various subtle points I
didn't mention.
It might be easier to write the multitasking shell as a real-mode
program, which _can_ switch stacks inside the timer tick handler, and
then run both programs from there.
The poor-man solution for this problem is simply to open 2 or more DOS
boxes on Windows ;-)
- Raw text -