Ana səhifə

Chapter 8 : ms-dos (Microsoft Disk Operating System) a single user single task operating system designed for Intel 80xxx chip based personal computers. History


Yüklə 69.96 Kb.
tarix25.06.2016
ölçüsü69.96 Kb.


Chapter 8 : MS-DOS (Microsoft Disk Operating System)
A single user single task operating system designed for Intel 80xxx chip based personal computers.
History:
1. Version 1.0 (1981).Based on 86-Dos (CP/M) operating system. The OS of the first IBM PC announced in August 1981. IBM PC used the Intel 8088 (16 bit bus) chip, had 64KB memory and a 4.77MHz clock rate. Although the chip had 1 MB addressing space, only the first 640KB was reserved as RAM and the remaining 386KB for video boards, and ROM's.
The OS occupied 12K and consisted of 3 programs; ibmbio.com (disk and character I/o system), ibmdos (disk and file manager) and command.com (command processor). The device drivers for standard devices such as the floppy, keyboard and screen are in ROM and called the BIOS (Basic input and output system). The BIOS resides just below the 1MB boundry in memory. This version was compatible with CP/M.

2. Version 2.0 (1983). This version was announced with the IBM PC/XT in March 1983. Features :

- Re-direction of standard I/O

- Pipelines and filters

- 360K diskette format

- User installable device drivers

- Print spooling

- System configuration

- Memory management

- Time, date, currency and decimal symbols for different countries (country.sys, nlsfunc) (version 2.05)
3. Version 3.0. In August 1984 IBM announced PC/AT based on the Intel 80286 (16 bit data, 16 bit bus, memory upto 16 MB). The chip also suppoerted user and kernel modes suitable for multitasking. PC/AT is shipped with MS-DOS 3.0. This version supported

- Extended memory (above 1MB)

- 1.2 MB diskette

- Disks larger than 10 MB

- RAM disks

- Command processor (command.com) became a separate program

- Version 3.1 (November 1984) supported networking for the first time (ethernet)

- Version 3.2 supported 3.5" diskettes and IBM token ring

- Version 3.3 came with IBM PS/2 in 1987. Diskettes now supported 3.5" 720 and 1.44MB formats, serial lines operating at 19,200 bps.
4. Version 4.0. Disks larger than 32 MB and menu-driven DOS shell.
5. Version 5.0 is released in April 1991. DOS now can be installed in HMA (1024-1088) so about 600K of 640K is free. Device drivers may be loaded to high memory between 640k and 1MB (himem.sys and emm386.exe). The shell is modified to support task swapping. A menu-driven screen editor (edit) to replace the line-by-line edlin. Extensive help is provided by HELP utility. Also the disk caching program SmartDrive shipped with Windows 3.1 is bundled with DOS 5.
6. Version 6.0 is released in mid 1993. This version provides

- Integrated disk compression (double space),

- Memory management (optimization of high memory (memmaker)

- Antivirus utility based on Central Point antivirus software CPAV

- Backup utility

- Disk optimization (defrag.exe) based on Norton's speedDisk.

- Multiple start-up options

- Improved SmartDrive disk cacher

- CD-ROM driver MSDEX

- Advanced Power Management (APM) for laptops

- File transfer utility (interlnk, intersrv)

Intel Chips : PC Magazine v.12 n.8 p.117


Cpu

Date

Clock

MIPS

Inter. Bus

Transistors

8080

April 1974

2 Mhz

0.64

8 bit

6,000

8086

June 1978

5 Mhz

0.33

16 bit

29,000

8088

June 1979

5 Mhz

0.33

16 bit

29,000

80286

February 1982

8 Mhz

1.2

16 bit

134,000

80386DX

October 1985

16 Mhz

6

32 bit

275,000

80386SX

June 1988

16 Mhz

2.5

32 bit

275,000

486DX

April 1989

25 Mhz

20

32 bit

1.2 million

486SX

April 1991

20 Mhz

16.5

32 bit

1.185 million

486DX2

March 1992

50 Mhz

40

32 bit

1.2 million


Pentium

May 1993

66 Mhz

112

64 bit

3.1 million


8086 : 16-bit registers, 16-bit bus, clock speeds of 4.77, 8, 10 Mhz.
8088 : 16-bit registers, 8-bit bus.
80286 : 16-bit bus. Protected mode (addressing above 640K) as well as the real mode. Clock speeds 10, 16Mhz.
80386DX: 32-bit registers, 32-bit bus, clock speeds 16, 20, 25, 33 Mhz. 4 GB memory.
80386SX : 16-bit bus.

486DX : Clock speeds of 25, 33, 50 Mhz, 8K instruction and data cache on chip, on chip floating point processor (487). Instruction execution in one clock cycle which virtually doubles the processing speed.

386SL : low power sx chip for notebook computers. The chip has power-management functions.
486SX : DX chip with floating-point coprocessor disabled.
486DX2 : 486 runs at twice the clock speed of the motherboard (clock-doubling). 25/50 , 33/66 Mhz clock speeds. Fastest 54 mips 66Mhz 486DX2.
486SL : 3.3 volt power saving 486 for notebooks.
Pentium : 64-bit data bus, 32-bit addressing, 8K data, 8K instruction cache, dual pipelining (prefetch, decode1, decode2, execute, and write-back) enabling instruction execution in one clock cycle, 16-bit segment registers and 4K pages (as in 386/486). 4MB pages are also available.
PROCESSES in MS-DOS
MS-DOS is not a multiprogramming system like UNIX and can not support multiple independent processes. ON the other hand, it is not a monoprogramming system either. It is something in between. When the system is booted, one process, command.com starts up and waits for input. When a line is typed, command.com starts up a new process and passes control to it, waiting until it is finished. This means that processes do not execute in parallel as in UNIX. You can create and start new processes but only one is active.
MS-DOS has two kinds of executable binary files :

- Files with .com extensions. These files have no header and only one segment (text + data + stack segment of at the most 64KB long). Such a file is loaded into memory as it is and executed. Even though the process size can not exceed 64K, it allocates all available memory. If such programs decide to create children then they have to return unused portion of memory back to the operating system so that this memory will be allocated to the new child.
- Files with .exe extensions. These files have a text segment, a data segment, a stack segment, and several extra segments. These files contain relocation information, so they can be relocated during loading. Exe files contain (Ox4D5A or "MZ" in the first two bytes).
The first 256 bytes of every MS-DOS process is a special data block called the PSP (Program Segment Prefix). For .com files, the PSP is a part of process address space and can be addressed as 0-255. In .exe files, the program is relocatable and the address 0 is right after the PSP. PSP is a simpler process context block and contains

- Program size,

- Pointer to the environment block,

- Address of the CTRL-C handler,

- Command string,

- Pointer to the parent's PSP,

- File descriptor table etc..
A child process in MS-DOS inherits its parent's open files and their file positions. Any files that the child opens are closed on exit, its memory is freed and an exit status is returned to the parent.
When a child is created it is the responsibility of the parent to provide the memory. This implies that the programmer take every precaution so that the the program will have a small nucleus and the rest swappable to disk. Off course, the swap operation has to be done by the program itself. MS-DOS does not provide swapping as available in other operating systems such as UNIX. Consider the case as shown below in which command.com calls an editor which has an exit to DOS in its menu.

Normally when a process terminates, its memory is reclaimed and the process vanishes forever. However MS-DOS also has an alternative way for a process to exit that instructs the system not to take back its memory, but to otherwise treat it as exited. This feature permits the writing of TSR (Terminate and Stay Resident) software.

This implies that we can load several programs one after the other into memory and let them stay there. The only problem is how we can activate these programs later on. The answer lies in MS-DOS permitting user defined interrupt handlers. The keyboard interrupt handler is modified to check the input for hot keys (special keyboard sequences such as ALT-F1, CNTL-SHIFT-A) associated with resident programs.

The MS-DOS Memory Model

The 8088 Memory Architecture
The family of 80xxx of Intel chips start with the 8080 of early 1970's. This 8-bit chip had several 8-bit registers, including an 8-bit accumulator and two 8-bit address registers, H and L, which were used as a 16-bit memory address register to access the 64K memory.
The successors to the 8080, the 8086 and 8088, were designed as backward compatible with 8080 to run 8080 programs. The 8088 has 12 16-bit registers;

- 4 arithmetic registers AX, BX, CX and DX which were made of two 8-bit registers for compatibility (for example, first byte of AX is register AH and second byte AL)

- 4 pointers registers SI, DI, BP, and SP. SI and DI are used as index registers, BP as a base pointer to local variable stack and SP as the stack pointer.

- 4 segment registers CS, DS, SS, and ES are segment registers. Each segment register holds the 16 high-order bits of a 20-bit address (1 MB). The low-order 4 bits are always zero. So the segment register points to a 16 byte memory space known as a paragraph. CS is the code segment register, DS is the data segment register, SS is the stack segment register and ES is the extra segment register. Segments are 64KB long.
Machine instructions on the 8088 contain 16-bit addresses and 16-bit offsets. The program counter is also 16 bits. Thus, memory references are always relative to the beginning of a segment. Therefore, to access a memory byte the 16-bit offset is added by the appropriate stack register content.
Note that only 128KB (4 64K segments) of memory can be directly addressed at any time in 8088. To refer to other parts of memory the segment registers have to be modified.



Memory Layout for Intel 80x Family of Chips


The High Memory Area
Segment registers with values between 0xF001 - 0xFFFF (addresses 960K-1023K i.e., the last 64KB segment below the 1MB) refer to addresses above 1MB. For example, a segment starting at 1023K cover the addresses 1024K to 1088K. The 64K segment starting at 1024K is called the HMA (High Memory Area). For 286 and later Intel chips the A20 address pin is wired like other pins enabling HMA to be used for memory. For DOS5 and over this space is used to load MS-DOS so it relieves 64KB of conventional memory. If the pin is grounded as in 8088 (or not enabled which is the default) the memory of HMA is mapped to the first 64K starting at 0KB.
Extended Memory
For 286 and later chips the memory above 1MB is called the extended memory. The 286 has 16 MB, 386 and 486 upto 4GB of memory. The CPU must be in protected mode to refer to these addresses. In real mode the chip behaves like 8088.
MS-DOS works in real mode. So the use of extended memory is difficult. With extended memory drivers such as QEMM, HIMEM and EMM386 this memory can be used for RAM disks and caches.
Windows 3.1 (in enhanced mode), OS/2 and UNIX operate in protected mode. Thus extended memory for these OSs is like conventional memory.

The Upper Memory Area
Initially IBM PC is designed in such a way that the first 640KB is allocated for DOS, device drivers and user programs. The next 384K between 640K and 1MB is reserved for video RAMs, BIOS, network cards, interface cards such as SCSI cards etc.. This memory region is called the UMA (Upper Memory Area). When you buy a PC with 4MB, the UMA region is not accessible. If you do not insert to many interface cards 200-300KB of the UMA is wasted. Drivers like QEMM, and HIMEM and EMM386 map unused RAM blocks (left after adapter, video and BIOS ROMs) as High Memory Areas or Upper Memory Blocks so that device drivers residing in conventional memory can be relocated.

Expanded Memory
For 8088 and above machines, programs requiring memory more than 640KB must be written using overlays under DOS. Extended memory can be used to some degree for data structures. Another method is the hardware method called the expanded memory.
The most common standard is the LIM EMS developed by Lotus, Intel and Microsoft.
The PC's 1MB address switch is split into 64 pages of 16K each. The expanded memory, upto 32MB, is split into as many as 2048 page frames, also 16K each. Special hardware on the expanded memory board card maps the 64 virtual pages onto any arbitrary set of physical page frames.
Note that, you can not write a program larger than 640K. Thus expanded memory management is not similar to paging but the opposite and much more similar to overlaying. In fact, a program's address space is still 640K (in contrast to paging which provides unlimited address space). The expanded memory in this case may be used by several program images for task swapping or for storing large arrays which have to be manipulated using a limited memory.
Furthermore, it is the programmers responsibility to map expanded memory onto 640K address space.
Expanded memory is not used anymore on 386 and above CPU's since extended memory is much simpler to manage since these chips support segmentation with paging.

Implementation of MS-DOS
MS-DOS is structured in three layers :
1. The BIOS (Basic Input Output System)

2. The kernel

3. The shell, command.com
The BIOS is a collection of low-level device drivers (eg., keyboard, screen, floppy). The BIOS is provided as a ROM which occupies the the 64K block just under the 1MB (0xf000-0xffff).
BIOS procedures are called by trapping them through interrupt vectors. The file io.sys (ibmbio.com) is loaded right after booting and provides a procedure call interface to the BIOS. This method provides flexibility so that when you replace your version of DOS new MS-DOS accesses ROM BIOS through new procedure calls.
The kernel is contained in msdos.sys (ibmdos.com) and handles process management, memory management, and the file system, as well as the system call interpretation.
The command.com shell has two portions; resident and transient portions. The resident portion is always in memory, and the transient is loaded to the HMA. This space can be used by user programs, command.com re-loads the transient part if destroyed.
Booting Procedure
1. When power is turned on, control is transferred to address 0xFFFF0 (in ROM) which contains the address of bootstrap loader in BIOS ROM.
2. Bootstrap loader; checks hardware (especially the memory) and then tries to read boot sector from drive A:. If drive A: has no diskette or one with no valid boot sector, the boot sector of primary hard disk is read in.
3. The partition table in the primary boot sector tells where the partitions are and which one is active (fdisk)
4. The first sector (secondary boot sector) of the active partition is read in and executed (this method provides booting other operating systems as well as MS-DOS).
5. The boot sector reads its own root directory, loads io.sys and msdos.sys, and transfers control to io.sys.
6. io.sys calls BIOS procedures to initialize the hardware then config.sys is read in by sysinit for system configuration.
7. Once config.sys processing is over sysinit uses MS-DOS itself (msdos.sys) to load and execute command.com.
8. Command.com reads and executes autoexec.bat


Memory layout after booting

Implementation of Processes in MS-DOS
When a process calls the LOAD_AND_EXEC system call to create a child, MS-DOS carries out the following steps:
1. Find a block of memory large enough to hold the child process. For an .exe file, the size is in the header. For .com file, all of the available memory is allocated, but the child may return unused memory if necessary.
2. Build the PSP in the first 256 bytes. A pointer in PSP points back to the parent.
3. Load the .exe or .com file after the PSP. Relocate the addresses if the file is an .exe.
4. Start the program. The starting address for an .exe is in the header. The .com file starts at 0x100 (after the PSP).

A global variable in the system points to the current PSP. Since PSP's are all linked it is possible to trace back all loaded programs. This is usefull for writing TSR's and displaying resident programs in memory.

TSR's modify these links so that the TSR's are jumped over to create new children.

Implementation of Memory Management in MS-DOS
MS-DOS memory is managed by chaining memory blocks as in process management. Memory blocks allocated to processes are called arenas. An arena starts at a paragraph and cantains a whole number of paragraphs. The first paragraph (16 bytes) is the arena header. This header contains; a pointer to the PSP of the process which allocated the memory, size of arena in paragraphs, and the name of the executable file which owns the arena.

When memory is required, the arena chain is searched from the beginning for an arena of required size. If the arena is too large, the arena is divided. When memory is freed, adjacent arenas can not be merged because the chain is not doubly linked. Merging occurs the next time the chain is searched.
The arena scheme does not work for extended memory since the sizes in arena header are only 16 bits. To use the extended memory a memory management driver such as himem.sys, emm386.exe, or Qemm has to be loaded.

Implementation of the MS-DOS File System
The layout of an hard disk is as follows:


The boot sector contains the bootstrap loader, as well as the critical information about the file system (number of bytes per sector, number of sectors per block, number of FAT's, size of the root directory, device size etc.). The partition table is also at the end of the boot sector. This table contains the start and end of each partition (max. of 4). One partition is always set as active for booting procedure.

File Allocation Table (FAT) is used to keep track of all disk space on the device. The FAT entry is 16 bits (12 bits for floppies) so for disks larger than 32 MB, clustering is used.


Directory Entries in MS-DOS :
The layout of an MS-DOS directory entry is shown below.


The time and date of last modification are strored in the following way:
- 6 bits for the seconds

- 6 bits for the minutes

- 4 bits for the hour

- 5 bits for the day

- 4 bits for the month

- 7 bits for the year (starting at 1980)


Open system call :
1. Access the file descriptor table (a 20 byte array in PSP of the process) for a free file descriptor. Each of the bytes in the file descriptor table holds a 1-byte index to the system file table (max. size 256, set by files=x in config.sys) or a not-in-use mark. If a free file descriptor entry is available, the system file table is searched for a free slot.
2. Examine the path name of the file to be opened for special file names such as con, lpt. If the file is not a special then check the first character for "\". If the character is a "\" then search starts from the root directory (absolute path), else the current directory is searched (relative path).
3. If the search is successful (ie., the file is found), the directory entry is copied into the system file table, which has one entry for each open file. This entry also holds the current file position.


Implementation of Input/Output in MS-DOS
All I/O in MS-DOS is done through character or block special files depending on the device. For each special file (device), there is a device driver which contains the actual I/O program.
Some of the drivers are already contained in io.sys (eg., com1, con, lpt1). Additional device drivers can be loaded at boot time using DEVICE command or in autoexec.bat. Each driver is a separate program, written in assembly language, C, or some other language, and compiled into an .com or .exe file. Drivers may also be given .sys extension.


I/O call progress :
1. A user program issues a READ or WRITE system call. Since the file is open, the I/O device is deduced by following the PSP and system file table.
2. A request message with a 13-or-more header is constructed. The message contains:

- Function code for the operation desired (read or write),

- Memory address to readto or write from (buffer address),

- Device address for block devices, and

- Byte count
3. The request handler of the device driver is called using the offset. This procedure examines the message and saves relevant fields.
4. The I/O code is called to do the actual I/O. Code address is obtained from the offset in driver header.
5. When the driver finishes work, it sets a status word indicating success or failure and returns control to its caller.



Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©atelim.com 2016
rəhbərliyinə müraciət