OSDev.org
https://forum.osdev.org/

DOS - What happens with the shell when a program is started
https://forum.osdev.org/viewtopic.php?f=1&t=33746
Page 1 of 1

Author:  IchMagBier [ Fri Jun 28, 2019 8:19 am ]
Post subject:  DOS - What happens with the shell when a program is started

Hi :)

So, I have a question about our beloved Disk Operating System: What happens with COMMAND.COM, when you start another program? I know that the new program is loaded at memory address 0x100 and then a "call" happens to that location, but what happens to the already loaded program (COMMAND.COM in this example) at 0x100? It's not completely gone, since your program can return to the previous running application. Is it loaded elsewhere? Does DOS move every program to another memory location when they start another app and then reload them to 0x100 when the sub-programs exits?

Author:  nullplan [ Fri Jun 28, 2019 8:42 am ]
Post subject:  Re: DOS - What happens with the shell when a program is star

The program is indeed loaded to 0x100. But the segment for that 0x100 is a different one each time. COMMAND.COM stays in memory, where it was before it called another program.

This is less wasteful than it could have been, since segments overlap a lot.

Author:  MichaelPetch [ Fri Jun 28, 2019 9:22 am ]
Post subject:  Re: DOS - What happens with the shell when a program is star

COMMAND.COM has two parts. There is the resident portion of COMMAND.COM. Usually this is in low part of conventional memory before the programs but can be loaded in the HIGH Memory Area (HMA) Between 1MiB and 1MiB+65520 if you are running HIMEM.SYS on a 386+. The second part of COMMAND.COM is the transient portion. This part usually sits at the top of the DOS free memory pool (usually below the top of conventional memory under the EBDA (and other hidden data/code). This part of COMMAND.COM is considered free memory and may be given to the program by the DOS loader or requested by the program that requests more memory. When a program exits, DOS determines if the transient portion of COMMAND.COM has been overwritten and then reloads it. If it hasn't been overwritten then it can be reused as is.

Author:  mallard [ Fri Jun 28, 2019 9:44 am ]
Post subject:  Re: DOS - What happens with the shell when a program is star

Even though DOS doesn't work this way, the very earliest single-tasking versions of what became UNIX could only have one process in memory at a time. They had a special mechanism to re-load the shell whenever another process terminated.

Of course, this was on a system with only about 4KB of memory and was replaced by a better mechanism pretty quickly...

The early single-tasking versions of Mac OS (then simply known as the "Macintosh System Software") did something similar with their graphical "Finder" shell, since even having one GUI application resident in 128KB was difficult, having multiple was out of the question.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/