www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/07/28/03:58:27

Date: Sat, 28 Jul 2001 09:51:45 +0300
From: "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il>
Sender: halo1 AT zahav DOT net DOT il
To: "Rafal Maj (Raf256)" <raf256 AT go2 DOT pl>
Message-Id: <3405-Sat28Jul2001095144+0300-eliz@is.elta.co.il>
X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.9
CC: djgpp AT delorie DOT com
In-reply-to: <9jthc4$l24$2@info.cyf-kr.edu.pl> (raf256@go2.pl)
Subject: Re: Dos program with multitasking
References: <9jthc4$l24$2 AT info DOT cyf-kr DOT edu DOT pl>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> 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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019