You are on page 1of 25


12 MS-DOS Operating System

History Design Goals Memory Management Processor Management Device Management File Management User Interface Additional Commands

Understanding Operating Systems


Developed to run single-user, stand-alone desktop computers. Exemplifies early OS because it manages jobs sequentially from single user. Advantages: fundamental operation & straightforward user commands. Disadvantages: 1. Lack of flexibility & limited ability to meet needs of programmers & experienced users. 2. Written for a single family of microprocessors (Intel family of chips: 8086, 8088, 80186, and 80286).
Understanding Operating Systems 2

History of DOS
Version Release date 1.0 1981 1.1 1982 2.0 1983 3.0 1984 3.1 3.2 3.3 4.0 5.0 6.0 6.22
Understanding Operating Systems

Features CP/M compatible; supported only 1 directory Allowed double-sided 5 inch disks Eliminated some defects in version 1 Increased memory requirement to 36K, supported PC/AT First release to support networking Supported token ring and 3 inch disks IBM PS/2 computer Supported hard disks larger than 32 megabytes Better use of extended memory Better use of conventional memory Provided users with capabilities previously available only as third party applications

1984 1986 1987 1988 1991 1993 1994

Design Goals



Understanding Operating Systems

Accommodate single novice user in single-process environment. Standard I/O support includes keyboard, monitor, printer, & secondary storage unit. User commands are based on English words/phrases indicative of action to be performed. Commands are interpreted by command processor. Layering approach protects user from hardware.

First 2 DOS Layers : BIOS & Kernel

1. BIOS (Basic Input/Output System) -- interfaces directly with various I/O devices. Device drivers (control flow of data to/from each device). Receives status info about success/failure of each I/O operation & passes it on to the processor. 2. DOS kernel -- routines needed to interface with the disk drives. Read into memory at initialization time from MSDOS.SYS file on boot disk. Accessed by application programs. Provides collection of hardware-independent services, such as memory management, & file & record management (system functions).
Understanding Operating Systems 5

Third DOS Layer : Command Processor

3. Command processor (shell) -- sends prompts to user, accepts commands, executes commands, & issues appropriate responses.
Resides in a file called COMMAND.COM, which consists of 2 parts stored in 2 different sections of main memory. Not interpretive. MS-DOS Version 4.0 -- menu-driven DOS shell. OS/2 -- designed to replace MS-DOS.

In its heyday, MS-DOS ran enormous collection of software packages making it difficult to discontinue.
Understanding Operating Systems 6

DOS Memory Manager

Relatively simple job because its managing single job for single user. Uses a first-fit memory allocation scheme since it is most efficient strategy in a single-user environment. Main memory: 1. Read Only Memory (ROM) -- very small in size & contains program, section of BIOS, with sole task of starting up system (bootstrapping). Retrieves remaining resident OS & loads it into RAM. 2. Random Access Memory (RAM) -- where programs are loaded and executed.
Understanding Operating Systems 7

Reserved for BIOS Unused Transient part of Command.COM Transient program Area (user memory)
TSR programs Resident part of Command.COM Installable Drivers Buffer Cache MS-DOS Kernel BIOS Interface Interrupt Vectors

1M 640K

RAM Layout for 1MB of Memory

Understanding Operating Systems

DOS Main Memory Allocation

First versions had simple contiguous memory allocation scheme that gave all available memory to resident application program.
Applications couldnt dynamically allocate memory blocks. Version 2.0, MS-DOS support dynamic allocation, modification, & release of main memory blocks by applications.

Amount of memory each application owns depends on type of file from which program is loaded & size of TPA.
Programs.COM -- given all of TPA, whether or not they need it. Programs.EXE -- given amount of memory they need.

Except for COM files, there can be any number of files in TPA at one time.
Understanding Operating Systems 9

Memory Block Allocation

Allocates memory by using first-fit algorithm & linked list of memory blocks.
With Version 3.3, use best-fit or last-fit strategy. With last-fit, allocates highest addressable memory block big enough to satisfy programs request.

Size of a block can vary from 16 bytes (paragraph) to maximum available memory.
Understanding Operating Systems 10

First 5 Bytes of Memory Block Define Blocks Structural Characteristics

Byte byte 0 bytes 12 Contents ASCII 90h if its the last block, or ASCII 77h if its not. Includes the number zero to indicate a busy block and the pointer to the Program Segment Prefix (PSP) that is created by the EXEC function when the program is loaded. bytes 34 Gives the number of paragraphs contained in the block.

Understanding Operating Systems


Free/Busy Block List

Whenever request for memory comes in, DOS looks through free/busy block list to find free block that fits. If list becomes disconnected, system stops & must be rebooted. Well-designed application program releases memory block it no longer needs.






Block 1

Block 2

Block 3

Block 4

Block 5

Understanding Operating Systems

Process Management
MS-DOS wasnt written in reentrant code because it was designed for a single-user, single-task environment. Reentrant code is basis for multitasking. Programs cant break out of middle of DOS internal routine & restart routine from somewhere else. There's no interleaving & no need for sophisticated algorithms or policies to determine which job will run next or for how long. Some software programs give illusion that two jobs can run together. E.g., Microsoft Windows versions 1.0 to 3.0. Possible because MS-DOS interrupt handlers give programmers capability to save all info about parent program that allows its proper restart after child program finishes.
Understanding Operating Systems 13

Interrupt Handlers Are Responsible for Synchronizing Processes

PC has 256 interrupts & interrupt handlers, & they are accessed via interrupt vector table residing in lowest bytes of memory.

1. Internal hardware interrupts -- generated by certain events occurring during programs execution (e.g., division by zero). 2. External hardware interrupts -- caused by peripheral device controllers or by coprocessors & assigned by manufacturers. 3. Software interrupts -- generated by system & application programs to access DOS & BIOS functions, which, in turn, access system resources. Terminate and Stay Resident (TSR) -- a process without releasing its memory, thus providing memory-resident programming facilities.
Understanding Operating Systems 14

Device Management
Ability to reorder requests to optimize seek & search time is not feature because its designed for a single-user environment. All requests are handled on a first-come first-served basis. Version 3.0 BIOS can support spooling so users can schedule several files to be printed one after the other. MS-DOS written for simple systems using keyboard, monitor, printer, mouse, 1-2 serial ports, & maybe second printer. Use one of each type of I/O device for each port, so no device channels. Devices do not require special management from OS. Device drivers are only items needed by Device Manager to make system work.
Understanding Operating Systems 15

File Name Conventions

File name consists of : Drive name (usually A, B, C, or D) is followed by a colon (:). Directories/subdirectories are 1-8 characters long & preceded by back slash (\). Primary file name is 1-8 characters long. Period. Extension is 1-3 characters long with possible special meaning.
Relative name --primary name & extension, if used. Absolute name -- drive designation & directory location (path) followed by its relative name.
Understanding Operating Systems 16

Managing Files
Earliest versions of MS-DOS kept every file in a single directory. Version 2.0 implemented hierarchical directory structure. Inverted tree directory structure. When disk is formatted its tracks divided into sectors of 512 bytes. 2-8 sectors are grouped into clusters & that's how File Manager allocates space to files. Supports hidden filesfiles that are executable but not displayed in response to DIR commands.
Understanding Operating Systems 17

FORMAT Creates Three Special Areas on Disk

1. Boot record -- first sector of every logical disk & contains disk boot program & table of disk's characteristics.
2. Root directory -- where system begins its interaction with user. Lists systems primary subdirectories & files (name, extension, size, date & time of modification, starting cluster #, file attribute codes).

3. FAT (File Allocation Table) -- contains status info about disks sectors: which are allocated, which are free, and which cant be allocated because of formatting errors.
Understanding Operating Systems 18

Managing Files in DOS

Looks at data in a disk file as a continuous string of bytes. I/O operations request data by relative byte (relative to beginning of file) rather than by relative sector. Transformation from physical sector to relative byte address is done by File Manager. Supports noncontiguous file storage & dynamically allocates disk space to a file, provided theres enough disk room. Compaction (MS-DOS Version 6.0) available via utility used to defragment disk (DEFRAG.EXE). CHKDSK command used to determine need for compaction. Restricting user access to computer system & resources isnt built into MS-DOS.
Understanding Operating Systems 19

User Interface
Command-driven operating system.
When user presses Enter key, shell (COMMAND.COM) interprets command & calls on next lower level routine to satisfy request. User commands include some or all of these elements in this order: command source-file destination-file switches
Understanding Operating Systems 20


Stands for Directory Change Directory Copy Delete Rename Type Print Date Time Make Directory Find Format Disk Check Disk System Prompt Defragment Disk

Action to be performed List whats in this directory. Change working directory. Copy a file. Append one to another. Delete the following file or files. Rename a file. Display text file on screen. Print one or more files on printer. Display and/or change system date. Display and/or change system time. Create a new directory or subdirectory. Find a string. Search files for a string. Logically prepare disk for file storage. Check disk for disk/file/directory status. Change system prompt symbol. Compact fragmented files. Run, execute, file.

Understanding Operating Systems


Batch Files & Redirection

By creating customized batch files, users can quickly execute combinations of DOS commands to configure their system, perform routine tasks, or make it easier for non-technical users to run software.
MS-DOS can redirect output from one standard input or output device to another. command > destination

Understanding Operating Systems


Filter Commands (SORT, MORE)

Filter commands accept input from default device, manipulate data in some fashion, & send results to default output device. SORT accepts input from keyboard, sorts that data, & displays it on screen. Sort the file by column. MORE causes output to be displayed on screen in groups of 24 lines, one screen at a time, & waits until user presses Enter key before displaying next 24 lines.
Understanding Operating Systems 23

Cause standard output from one command to be used as standard input to another command.
Symbol is a vertical bar, |. Alphabetically sort directory & display sorted list on screen: DIR | SORT

Combine pipes and other filters.

Understanding Operating Systems 24

Other Commands
FIND -- filter command that searches for specific string in given file or files & displays all lines that contain string from those files. PRINT -- allows user to set up series of files for printing while freeing up COMMAND.COM to accept other commands.

Understanding Operating Systems