Tuesday, November 24, 2009

Conventional Memory

The first 640 KB of system memory is called conventional memory. The name refers to the fact that this is where DOS, and DOS programs, conventionally run. Originally, this was the only place that programs could run; today, despite much more memory being added to the PC, this 640 KB area remains the most important in many cases. The reason is that without special software support, DOS cannot run programs that are not in this special area. Conventional memory occupies addresses 00000h to 9FFFFh.
Why is there a 640 KB "barrier"? The reason is the ill-fated decision by IBM to put the reserved space for system functions above the memory dedicated for user programs, instead of below it, in combination with two decades of preserving compatibility with the first processors, which couldn't address over 1 MB of memory. This has caused the conventional memory area to be separated from the rest of the usable memory in the PC (extended memory). If the reserved area had been placed below conventional memory, it may have been possible to simply expand the conventional memory space, but it still may not have happened (who knows).
As programs grew in size and complexity in the 1980s, programs strained to fit into their increasingly tight 640 KB "clothing". The problem was exacerbated by the fact that the 640 KB wasn't all available: parts of it are used by DOS routines themselves, along with interrupt vector tables, buffers for file access, and drivers for CD-ROM drives, disk compression, and network access. Because of this, many PC users found that after DOS had booted up, they typically had as little as 550 or even 500 KB free for running programs. Meanwhile, program developers were straining and squeezing to try to get their programs small enough for people to be able to use them. The end result was usually a lot of problems. I have seen PCs that, without optimization, boot up with less than 400 KB free of usable memory. Many programs will refuse to load with less than 500 KB free.
To counter some of these problems, Microsoft made two enhancements to MS-DOS. The first is the ability to load DOS itself into the high memory area, the first 64 KB of extended memory. Due to a quirk in how the PC works, this area can be accessed by DOS. This saves about 45 KB of conventional memory. The second is that it is possible to load some device drivers (not user programs generally) into open portions of the upper memory area (the reserved 384 KB between conventional memory and extended memory), so they aren't taking up space in conventional memory. This has its own set of issues associated with it.
Maximizing conventional memory has become one of the "fine arts" of setting up a new PC that uses DOS programs. Utilizing the high memory area and upper memory area, combined with special tricks and experience, knowledgeable computer people can get all the drivers necessary to run the system loaded with still as much as 620 KB free for programs. (You can never get all 640 KB free, as some space is always used for system functions.
Tip: You can use the DOS command "MEM /C /P" to see how much conventional memory is used and free.
In newer operating systems that run in protected mode--which means basically every operating system other than DOS--conventional memory is much less important. These programs are able to make use of extended memory for running programs. 32-bit operating systems like Windows 95 can also use extended memory for its hardware drivers. Certain parts of the code must still run in conventional memory, but since applications are not trying to cram in there also there usually isn't a problem.
Bear in mind that when you use a DOS program from within an operating system like Windows 95, the same conventional memory restrictions apply. When running in a DOS box with Windows 95 still active, the drivers used are still those that Windows 95 loaded into extended memory, so there aren't usually any problems. However, many users run into trouble when they boot into "MS-DOS mode". When you do this, you are back to real mode and the extended memory drivers used under Windows 95 are not available. In order to use your CD-ROM drive, sound card and many other devices, you have to use real mode drivers, which must go either in conventional memory or in the upper memory area. Many times this can cause memory shortages.

No comments:

Post a Comment