DOS - What happens with the shell when a program is started

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
IchMagBier
Posts: 3
Joined: Sun Dec 16, 2018 6:18 am

DOS - What happens with the shell when a program is started

Post by IchMagBier »

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?
nullplan
Member
Member
Posts: 1647
Joined: Wed Aug 30, 2017 8:24 am

Re: DOS - What happens with the shell when a program is star

Post by nullplan »

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.
Carpe diem!
MichaelPetch
Member
Member
Posts: 712
Joined: Fri Aug 26, 2016 1:41 pm
Freenode IRC: mpetch

Re: DOS - What happens with the shell when a program is star

Post by MichaelPetch »

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.
mallard
Member
Member
Posts: 280
Joined: Tue May 13, 2014 3:02 am
Location: Private, UK

Re: DOS - What happens with the shell when a program is star

Post by mallard »

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.
Image
Post Reply