OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 12:32 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: DOS - What happens with the shell when a program is started
PostPosted: Fri Jun 28, 2019 8:19 am 
Offline

Joined: Sun Dec 16, 2018 6:18 am
Posts: 3
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?


Top
 Profile  
 
 Post subject: Re: DOS - What happens with the shell when a program is star
PostPosted: Fri Jun 28, 2019 8:42 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
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!


Top
 Profile  
 
 Post subject: Re: DOS - What happens with the shell when a program is star
PostPosted: Fri Jun 28, 2019 9:22 am 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 671
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.


Top
 Profile  
 
 Post subject: Re: DOS - What happens with the shell when a program is star
PostPosted: Fri Jun 28, 2019 9:44 am 
Offline
Member
Member

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


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 103 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group