ID Number: Q61383
2.x 3.x 4.00 4.01
MS-DOS
Question:
I am writing a "shell" program to allow a user to move transparently
between several programs that make up an application. One of the
programs this shell must execute is very large; currently, it is hard
to fit this program into 640K (even with overlays). I can easily
invoke these programs from the shell using the 4BH (EXEC) call, but
the shell program continues to take up memory. Is there a way of
"chaining" from one process to another, with the caller being replaced
by the callee, or is there a way to reduce the amount of memory
occupied by the shell program to the minimum required to execute the
large program? I suspect the latter could be done with SETBLOCK, but
when the large program returns, how would I reload the rest of the
shell process?
Response:
Unfortunately, there is no way of "chaining" from one process to
another with the caller being replaced by the callee.
However, you can reduce the amount of memory occupied by the shell
program to the minimum. You can shrink it down as much as you can with
MS-DOS Interrupt 21H, service 4AH, SETBLOCK. If your shell program is
a .COM program, you will definitely need to do this, since .COM files
by default allocate all available memory when they are executed.
To write a shell program that allows the most room for called
applications, you should have a small core program with the bulk of
the application in one or more overlay files. When you first start up
the shell program, you would load in the overlays and have full
functionality. When you are about to execute a large program, you
would then jump back to the code in your core program, use SETBLOCK to
free up the memory taken up by your overlay(s), and then use EXEC to
load and execute the application. When this application is finished,
you would reload your overlays to restore the full functionality to
your shell program and then proceed with your program.