11
MS-DOS
Internals
MS-DOS
• At one time, the world’s most common
microcomputer operating system
• Absorbed by Windows
• Line commands still available
– The Windows XP command line
– See Chapter 7
© 2005 Pearson Addison-Wesley. All rights reserved
Figure 11.1 The components of a typical
operating system.
Memory
Resident operating system
• Resident
System constants and
parameters
– In memory at
all times
Interrupt handling routines
Resource management routines
• Transient
– In memory as
needed
– Transient OS
routines
– Applications
© 2005 Pearson Addison-Wesley. All rights reserved
Command processor
System disk
Input/output control system
File system
Printer
Transient area
Figure 11.2 The MS-DOS command
processor is called COMMAND.COM.
COMMAND.COM
Resident routines
MS-DOS is
command driven
Other operating system
components
Transient area
© 2005 Pearson Addison-Wesley. All rights reserved
Figure 11.3 IO.SYS and MSDOS.SYS
share responsibility for communicating
with peripheral devices.
• IO.SYS
– Hardware dependent
– Physical I/O
– Interacts with BIOS
• MSDOS.SYS
COMMAND.COM
Logical
request
MSDOS.SYS
– Hardware independent
– Logical I/O
IO.SYS
© 2005 Pearson Addison-Wesley. All rights reserved
Physical I/O
operation
Figure 11.4 MSDOS.SYS uses a device
driver to translate logical I/O requests to
physical form.
• Character driver
– Keyboard
– Screen
– Printer
Logical I/O
request
MSDOS.SYS
• Block driver
Device
driver
– Disk
– 512-byte blocks
• CONFIG.SYS
– System file
– Device descriptions
© 2005 Pearson Addison-Wesley. All rights reserved
IO.SYS
The file system (MSDOS.SYS)
•
•
•
•
Converts logical I/O to physical form
Performs directory management
Supports application programs
Allocates space on disk
© 2005 Pearson Addison-Wesley. All rights reserved
Figure 11.5 MSDOS.SYS is responsible
for directory management.
COMMAND.COM
MSDOS.SYS
Directory management
Read
directory
Create
Delete
Update
Directory
Program Book
Stats
IO.SYS
a. Following MKDIR,
COMMAND.COM calls
MSDOS.SYS.
© 2005 Pearson Addison-Wesley. All rights reserved
Directory copy
Rewrite
directory
COMMAND.COM
MSDOS.SYS
Directory management
Read
directory
Create
Delete
Update
Directory
Program Book
Stats
IO.SYS
b. MSDOS.SYS
calls IO.SYS to
read the directory.
© 2005 Pearson Addison-Wesley. All rights reserved
Program Book
Stats
Rewrite
directory
COMMAND.COM
MSDOS.SYS
Directory management
Read
directory
Directory
Program Book
Create
Delete
Update
Rewrite
directory
Stats
IO.SYS
c. MSDOS.SYS adds a
new directory entry.
© 2005 Pearson Addison-Wesley. All rights reserved
Program Book
Stats
Letters
COMMAND.COM
MSDOS.SYS
Directory management
Read
directory
Create
Delete
Update
Rewrite
directory
Directory
Program Book
Stats
Letters
IO.SYS
d. MSDOS.SYS
calls IO.SYS to
rewrite the
directory to disk.
© 2005 Pearson Addison-Wesley. All rights reserved
Program Book
Stats
Letters
Application program I/O
• Open/Close
– MSDOS.SYS calls IO.SYS
• Read/Write
– Program calls MSDOS.SYS
– MSDOS.SYS calls IO.SYS
© 2005 Pearson Addison-Wesley. All rights reserved
Figure 11.6 The format of a typical MSDOS system disk.
• MSDOS.SYS
– Allocates space
– Clusters
• File allocation
table (FAT)
© 2005 Pearson Addison-Wesley. All rights reserved
Figure 11.7 A file’s clusters are linked by a
chain of pointers in the file allocation
table.
Directory
FAT
File name
First
cluster
IO.SYS
MSDOS.SYS
COMMAND.COM
MYFILE
LETTERS
8
11
16
20
22
© 2005 Pearson Addison-Wesley. All rights reserved
Cluster Pointer
0-7
8
9
10
11
.
.
.
20
21
22
23
24
25
System
9
10
FF
12
.
.
.
21
24
23
FF
FF
Note: FF
means end
of chain.
Interrupt
• An electronic signal that results in the
forced transfer of control to an interrupt
handler
– Source: hardware or software
• Up to 256 different interrupt handlers
– Found in MSDOS.SYS or IO.SYS
© 2005 Pearson Addison-Wesley. All rights reserved
Processor
IP register
Figure 11.8 MS-DOS
interrupt processing.
Address in
application program
Operating system
a. The contents of the
instruction pointer (IP)
register are copied to
the stack.
Address of interrupt
"x" routine
Interrupt vectors
Stack
Address in
application program
Interrupt "x" routine
Application program
© 2005 Pearson Addison-Wesley. All rights reserved
Processor
IP register
Address of interrupt
"x" routine
b. The specified
interrupt vector is
loaded into the
instruction pointer.
Operating system
Address of interrupt
"x" routine
Interrupt vectors
Stack
Address in
application program
Interrupt "x" routine
Application program
© 2005 Pearson Addison-Wesley. All rights reserved
Processor
IP register
c. The first instruction
in the interrupt
processing routine is
fetched.
Address of interrupt
"x" routine
Operating system
Address of interrupt
"x" routine
Interrupt vectors
Stack
Address in
application program
Interrupt "x" routine
Application program
© 2005 Pearson Addison-Wesley. All rights reserved
Processor
IP register
d. The contents of
the stack are
loaded back into
the instruction
pointer register and
the application
program resumes
processing.
Address in
application program
Operating system
Address of interrupt
"x" routine
Interrupt vectors
Stack
Address in
application program
Interrupt "x" routine
Application program
© 2005 Pearson Addison-Wesley. All rights reserved
Figure 11.9 Hardware reads the boot
routine from the first sector on the system
disk.
© 2005 Pearson Addison-Wesley. All rights reserved
Interrupt vectors (first 1K)
Figure 11.10 The
contents of memory
after MS-DOS is booted.
IO.SYS
MSDOS.SYS
COMMAND.COM (resident)
Transient area
COMMAND.COM (overlay)
© 2005 Pearson Addison-Wesley. All rights reserved
Running MS-DOS
• Operating system booted
– Initial system prompt displayed
• User enters a command
– Enter key generates interrupt
• COMMAND.COM carries out command
– Call other MS-DOS components as necessary
– Example: load and start application
• System waits for next command
© 2005 Pearson Addison-Wesley. All rights reserved