WW0335: Memory Management with Windows 3.0 and 3.1Last reviewed: May 1, 1997Article ID: Q66420 |
3.00 3.00a 3.10 3.11
WINDOWS
kbfile kbenv kbhw kbappnote
The information in this article applies to:
Microsoft Product Support Services offers an Application Note that describes memory management with Microsoft Windows. This Application Note,"WW0335: Memory Management with Windows," examines the three types of memory that Windows versions 3.0 and 3.1 can use (conventional, extended, and expanded) and discusses how the three modes of Windows (real, standard, and enhanced) operate and use memory. You can obtain this Application Note from the following sources:
THE TEXT OF WW0335
Microsoft Product Support Services Application Note (Text File) WW0335: Memory Management with Windows Revision Date: 4/92 No Disk IncludedThe following information applies to Microsoft Windows version 3.1.
-------------------------------------------------------------------- | INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY | | ACCOMPANY THIS DOCUMENT (collectively referred to as an | | Application Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY | | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO | | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A | | PARTICULAR PURPOSE. The user assumes the entire risk as to the | | accuracy and the use of this Application Note. This Application | | Note may be copied and distributed subject to the following | | conditions: 1) All text must be copied without modification and | | all pages must be included; 2) If software is included, all files | | on the disk(s) must be copied without modification [the MS-DOS(R) | | utility DISKCOPY is appropriate for this purpose]; 3) All | | components of this Application Note must be distributed together; | | and 4) This Application Note may not be distributed for profit. | | | | Copyright 1992 Microsoft Corporation. All Rights Reserved. | | Microsoft, MS-DOS, and the Microsoft logo are registered | | trademarks and Windows is a trademark of Microsoft Corporation. |
INTRODUCTIONThis application note outlines the memory management capabilities of Microsoft Windows versions 3.0 and 3.1. References that apply to both versions will refer to Microsoft Windows versions 3.x. Microsoft Windows versions 3.x provide a protected mode graphical operating environment that runs existing MS-DOS applications and allows Windows applications to break the 640K barrier. Windows 3.1 memory management is simpler in many ways than that of previous versions. However, the flexibility of Windows 3.1 memory management continues to present a challenge to those who want to understand its operation in depth. This document examines the three types of memory that Windows 3.x can use or provide (conventional, extended, and expanded) and discusses how both standard and 386 enhanced modes of Windows 3.1 operate and use memory.
MEMORY TYPESThree different kinds of memory can be installed in your machine: conventional, extended, and expanded memory. In addition, IBM- compatible machines contain a 384K upper memory area (UMA).
Conventional MemoryConventional memory is the first 640K of memory in your machine. MS- DOS has a limit of 1024K of addressable memory (conventional memory plus the UMA), and all MS-DOS applications must run within this conventional memory. All Windows 3.x operating modes share this limitation for running MS-DOS applications, but standard and 386 enhanced modes break the 640K limitation for running Windows applications. Windows 3.x enhanced mode can create multiple virtual MS- DOS machines (for more information on virtual MS-DOS machines, see the section of this application note called "386 Enhanced Mode and Conventional Memory."
NOTE: 386 enhanced mode Windows 3.1 also allows MS-DOS applications to break the 640K barrier if they are written to use the Microsoft DOS Protected Mode Interface (DPMI) specification. DPMI allows MS- DOS applications to run in protected mode under Windows 3.1, using up to 16 megabytes (MB) of extended memory directly. Applications must be specifically written for DPMI in order to take advantage of this feature. 384K Upper Memory Area (UMA)Between the top of conventional memory at 640K and the start of extended memory at 1024K lies the 384K UMA. This area does not contain physical memory. Mapped into the 384K UMA are the system BIOS (basic input/output system) ROM chips and the display adapter memory. When you install other accessory cards, such as network adapters, they may also occupy space within the 384K UMA. It is important to remember that the 384K UMA is always located in the same area of the IBM- compatible computer's address space: from 640K to 1024K (A000 to FFFF hexadecimal). There are no exceptions to this rule. This means that a standard IBM-compatible machine with 640K of conventional memory installed really has 1 MB of address space. The system memory occupies the first 640K, and the 384K UMA occupies the area from 640K to 1 MB (1024K). This does not mean that the machine has 1 MB of memory. A machine with 1 MB of physical memory has an address space of 1408K. This consists of the 640K of conventional memory, the 384K UMA, and the 384K of extended memory starting at 1024K.
Extended MemoryExtended memory is the simplest type of add-on memory to understand. It is also the type of memory used by Windows 3.x running in either standard or 386 enhanced operating mode. Extended memory is a seamless continuation of the original 1 MB address space on 80286 and 80386 computers. Extended memory always starts exactly at 1024K, where the 384K UMA ends. There are no exceptions. It is not possible for an 8086 or 8088 machine to have extended memory. This is a hardware limitation of the 8086/8088 processors, which can handle only 1024K of total address space (that is, 640K of system memory plus the 384K UMA). This is one reason why Windows 3.1 cannot run on 8086/8088-based machines, as it requires a minimum of 256K of extended memory (or 1024K for enhanced mode). The 80286 processor can address 16 MB of total memory, and the 80386 processor can address up to 4 gigabytes (GB).
NOTE: PC manufacturers often refer to extended memory as expansion memory, which is not to be confused with expanded memory.Windows 3.x and all applications running under Windows 3.x access extended memory through the Microsoft Extended Memory Specification (XMS). Rather than accessing extended memory directly, access is made through an XMS driver. The driver supplied by Microsoft for this purpose is called HIMEM.SYS. Older MS-DOS applications that check available extended memory through interrupt 15, service 88H will not see any extended memory with an XMS driver loaded. Such applications must be rewritten to use the XMS, instead of interrupt 15, to access extended memory.
Expanded MemoryVersions of Windows prior to 3.0 used mostly expanded memory. Windows 3.x does not use expanded memory but may be able to provide it to MS- DOS applications. It is important to understand the concept of expanded memory if you still run MS-DOS applications that use it. There are two different kinds of expanded memory, differentiated by their Lotus/Intel/Microsoft (LIM) Expanded Memory Specification (EMS) version numbers.
LIM 3.2 Expanded MemoryWe discussed earlier how PC/XT machines with 8086/8088 processors can address only 1024K of memory, of which only 640K can be used as RAM for MS-DOS and MS-DOS applications. You can't add more than 640K of conventional memory to the system, but you can provide more than 640K through a technique called bank switching. Expanded memory uses an empty area in the 384K UMA of the machine to provide this functionality. To use an expanded memory card, you must load a device driver to let the card know how to communicate with the PC. This device driver is called an expanded memory manager (EMM). A LIM 3.2 EMM establishes a 64K page frame within the 384K UMA to perform EMS bank switching. The 64K page frame consists of four contiguous 16K pages. LIM 3.2 expanded memory won't work without a 64K contiguous page frame. The page frame is the area where the EMM maps information into and out of the RAM of the expanded memory card. Information is not physically copied from the EMS card to the RAM of the computer; the device driver simply makes the page frame point to the data on the expanded memory card. The data then appears in the page frame, and your application can access it.
LIM 4.0 Expanded MemoryLIM 3.2 expanded memory is fine for storing data such as spreadsheets in expanded memory; however, because the LIM 3.2 specification does not allow programs to run in expanded memory, it is not useful for multitasking. There are two of major differences between LIM 3.2 and 4.0. First, with LIM 4.0 you can have many more than four 16K pages. LIM 4.0 supports up to 64 pages, which are enough to bank 1 MB of memory at once. Second, the page frame itself no longer must be four contiguous 16K pages. In fact, you need no page frame at all. Whichever EMS version you are dealing with, the basic operating principle of bank switching is still at work. Although LIM 4.0 is a standard that offers many advantages over LIM 3.2, few applications have yet been written to take advantage of LIM 4.0.
BackfillingWith LIM 4.0's limit of 64 16K pages, you have enough pages to bank switch the entire conventional address range of the processor. However, there must be no active ROM or RAM of any sort where you put an expanded memory page. Thus, you can't map EMS pages on top of anything that is already occupying address space in your machine (such as loaded MS-DOS or video/system ROM). On the 80286 processor, you should disable as much motherboard memory as possible (down to 256K) and let the expanded memory card supply that memory. This process is called backfilling. This doesn't mean that your computer will have only 256K--your programs still see a 640K machine. But because the expanded memory card is now supplying the memory, it can bank switch the memory. This capability is called "large page frame" EMS, and it allows programs to run executable code in expanded memory, a major improvement over LIM 3.2. The 80386 processor has a built-in ability to readdress any page of memory to any other location. This means you don't have to backfill on an 80386 to get large page frame LIM 4.0 functionality, nor do you need an expanded memory board. It's easy to convert your 80386's extended memory to expanded memory with an 80386 EMM such as Microsoft's EMM386.EXE. If you're using an expanded memory board on an 80386 machine, read your manual carefully before you backfill. Not all memory boards have the register support to supply more than four 16K pages (LIM 3.2). Though a memory driver may conform to the LIM 4.0 specification, that does not mean the hardware can provide more than four pages. Also, because Windows 3.1 supports extended memory directly, backfilling expanded memory will not give you any advantages, and the memory on the motherboard is often faster than memory on an expanded memory board.
LIMulatorsSome programs, known as LIMulators, emulate expanded memory on 8088- and 80286-based machines using hard disk space and/or extended memory. These programs are not much of an advantage, because although they supply expanded memory, they are not hardware. They must locate a 64K EMS page frame in conventional memory and also take up space for the driver itself. LIMulators generally take close to 80K of conventional memory to run. Because conventional memory is the most precious memory on your machine, we do not recommend these types of programs. They are also typically extremely slow. On 80386 machines, it is possible to use a 386 expanded memory manager (such as EMM386 or Quarterdeck's QEMM) to emulate expanded memory. These LIMulators use the XMS rather than interrupt 15 memory to emulate expanded memory and are much more efficient than other types of LIMulators.
Expanded Memory DifficultiesLIM 3.2 expanded memory requires a page frame to work, and the page frame is located within the 384K UMA of your machine. Unfortunately, your EMM is not the only competitor for that memory space. Add-on boards, such as network cards; 3270 emulation cards; RLL, SCSI, and ESDI disk controllers; and even high-resolution video cards, can contend for this address space. Several potential difficulties can arise due to this contention:
WINDOWS 3.X MODES AND MEMORY USAGE: HOW EACH MODE WORKSThis section examines how standard and 386 enhanced mode Windows 3.x use the different types of memory we have discussed (conventional memory, the 384K UMA, extended memory, and expanded memory).
NOTE: Real mode is not available in Windows 3.1. Real mode for Windows 3.0 was supplied mainly for compatibility with older Windows 2.x applications. Most, if not all, of these older applications have now been updated to work properly with Windows 3.x. Valuable development time was saved in not maintaining this outdated mode, time that was then spent improving the two remaining Windows modes. STANDARD MODE WINDOWS 3.1: BREAKING THE 640K BARRIER ON 286 MACHINES
Standard Mode and Conventional MemoryWhen standard mode Windows 3.1 is started, it adds the amount of free conventional and extended memory and looks at the total amount as one contiguous block of memory. Conventional memory has no special meaning under standard mode, except when running MS-DOS applications. While standard mode Windows 3.1 has MS-DOS application sup-port, the MS-DOS application(s) must run within conventional memory.
Standard Mode and the 384K Upper Memory Area (UMA)In standard mode, Windows 3.x does not directly access the 384K UMA. Still, if a physical expanded memory board is present (or if a 386 memory manager is providing expanded memory under Windows 3.1), the EMM will use areas of the 384K UMA in order to provide a LIM 3.2 page frame. If you suspect a 384K UMA conflict is causing a problem, temporarily remove the external EMM for testing.
Standard Mode and Expanded MemoryStandard mode Windows 3.1 does not use expanded memory. MS-DOS applications running under standard mode can access expanded memory only if a physical expanded memory board, along with the appropriate memory manager, is present in the machine. Compatible 386 EMMs such as EMM386.EXE can be loaded to provide expanded memory outside Windows. However, 386 EMMs cannot be used to provide expanded memory to MS-DOS applications running in standard mode Windows. If possible, the 386 EMM will be disabled when standard mode loads. For more information on using expanded memory with standard mode see the "Expanded Memory for MS-DOS Applications" section of this application note.
Standard Mode and Extended MemoryWindows 3.x standard mode can access extended memory directly. It adds free conventional memory and free extended memory. It then provides the total as memory for Windows applications to use (minus the memory required by standard mode Windows itself). Standard mode accesses extended memory through the XMS driver HIMEM.SYS. MS-DOS applications that use extended memory can also be run from standard mode Windows.
386 ENHANCED MODE WINDOWS 3.X: ENTERING THE WORLD OF VIRTUAL MEMORY
386 Enhanced Mode and Conventional MemoryWindows 386 enhanced mode deals with conventional memory in much the same way that standard mode does. When 386 enhanced mode Windows 3.1 is started, it adds the amount of free conventional and extended memory; in addition, Windows 3.1 can use hard disk space as virtual memory (the "swap" file) and look at the total amount as one contiguous block of memory. Conventional memory has no special meaning under 386 enhanced mode, except when running MS-DOS applications. In 386 enhanced mode, MS-DOS applications run by creating virtual MS-DOS machines with up to 640K of free memory. Each virtual MS-DOS machine inherits the environment that was present before Windows 386 enhanced mode was started. This means that every driver and terminate-and-stay-resident (TSR) program loaded before you run Windows, as well as the environment, is present and consumes memory in every subsequent virtual MS-DOS machine. The net memory available within virtual MS-DOS machines under 386 enhanced mode is slightly less than the free memory at the MS-DOS prompt before you start Windows, due to the overhead of creating and managing a virtual machine.
386 Enhanced Mode and the 384K Upper Memory Area (UMA)Windows versions prior to 3.0 used the 384K UMA only to place the expanded memory page frame, and then to a maximum of only four 16K pages. Windows 386 enhanced mode uses the 384K UMA for two purposes:
API Translation Buffers in the 384K Upper Memory Area (UMA)Although Windows 3.1 386 enhanced mode breaks the 640K barrier for Windows applications, it still runs on top of MS-DOS. The copy of MS- DOS upon which Windows is running can execute and access data only within conventional memory. The same restriction applies to network software or other drivers loaded before 386 enhanced mode Windows. 386 enhanced mode allocates buffers in the 384K UMA to translate MS-DOS and network API calls from protected mode to real mode. Since the 384K UMA is within the first megabyte of address space, it can be accessed by MS-DOS in real mode. The translation buffers are used as a window through which applications running in protected mode can pass information to and from MS-DOS and the network drivers. Ideally, there would be enough free space in the 384K UMA to place both the translation buffers and the expanded memory page frame. Yet on many configurations there isn't enough room, and on those systems you have to make a choice. Either the expanded memory page frame can be eliminated, or the translation buffers can be allocated in conventional memory instead of in the 384K UMA. If the translation buffers are allocated in conventional memory, they take up space in every virtual machine that you create from Windows, and you will have less space in which to run MS-DOS applications. The translation buffers can be allocated either in the 384K UMA or in conventional memory, but never half and half. Fortunately, Windows 386 enhanced mode provides a method for specifying your preference. To do this, place the following setting in the [386enh] section of the SYSTEM.IN file:
ReservePageFrame=BooleanIf ReservePageFrame=true (the default), 386 enhanced mode Windows allocates the page frame first and the translation buffers second. This makes it likely that the translation buffers will be forced into conventional memory, but allows you to use expanded memory in MS-DOS applications. If ReservePageFrame=false, the translation buffers are allocated first and the page frame second if there is still room. The ReservePageFrame=false provides the most free memory within virtual machines, although some MS-DOS applications may not be able to use expanded memory. Remember, however, that Windows applications do not need expanded memory to function; only MS-DOS applications that can use expanded memory will be affected.
NOTE: If you are using the EMM386.EXE driver, translation buffers are always placed in conventional memory. Page Frame Placement in the 384K Upper Memory Area (UMA)As noted in the expanded memory discussion earlier in this application note, expanded memory support requires a page frame located in the 384K UMA. With LIM 4.0 expanded memory, it is not necessary to have a 64K contiguous page frame in this area. In fact, it's not necessary to have a page frame at all in LIM 4.0. Still, if you want to use expanded memory in your MS-DOS applications, you must have a 64K contiguous page frame (composed of four contiguous 16K pages in the 384K UMA) because most applications are written to take advantage of LIM 3.2 expanded memory. On a typical IBM-compatible machine there are only 12 free 16K pages in the 384K UMA, and on some machines (such as IBM PS/2s) there are only 8. Four contiguous pages are required for expanded memory support in MS-DOS applications, leaving only eight other free pages. Other items such as network adapters and many hard disk controllers, also need to occupy pages in the 384K UMA. Frequently, the combination of installed adapters can break up the free area in the 384K UMA so there is no 64K contiguous area in which to place the page frame. In this case, you will not see any free expanded memory in your MS-DOS applications. If you experience this problem, you may need to rearrange your adapter memory locations to get expanded memory support for MS-DOS applications. This is easiest to do on machines using the Micro Channel Architecture (MCA) or Extended Industry Standard Architecture (EISA) bus standards. IBM PS/2 models 50 and above are equipped with the MCA bus. PS/2 machines allow you to change adapter memory locations simply by restarting with the PS/2 Reference Disk and choosing Change Configuration. A similar procedure is available on most EISA bus machines, such as the COMPAQ SYSTEMPRO and the HP Vectra 486. Normal Industry Standard Architecture (ISA) bus machines such as the IBM PC/AT and COMPAQ 386 may require you to open the case and flip DIP switches or move jumpers on the cards to change memory addresses; check your hardware manual for more information on changing memory addresses. You can entirely disable expanded memory support under Windows 386 enhanced mode by adding the NoEMMDriver=yes setting to the [386enh] section of the SYSTEM.INI file.
Controlling 386 Enhanced Mode 384K Upper Memory Area (UMA) MappingIn versions of Windows prior to 3.0, the WIN.INI file settings EMMExclude= and EMMInclude= were used to control expanded memory page frame placement. These settings are used under Windows 386 enhanced mode to control not only the expanded memory page frame but also the API translation buffer mapping. Under Windows 3.x these settings begin with the letters "EMM" only for compatibility reasons; they no longer apply only to expanded memory. The EMMPageFrame= setting, however, still applies only to the expanded memory page frame. In Windows 3.x these three settings have been moved from the WIN.INI file to the [386enh] section of the SYSTEM.INI file. Earlier versions of Windows (2.x) do not use the E000-EFFF range of the 384K UMA unless specifically instructed to do so. Windows 386 enhanced mode will use this segment unless the machine identifies itself as a PS/2. To explicitly exclude an area of the 384K UMA from mapping by Windows 386 enhanced mode, use the EMMExclude= setting. The EMMExclude= setting accepts a four-digit hexadecimal memory range, such as EMMExclude=E000-EFFF. Since there is no standard for hardware implementation of the E000-EFFF area, it is frequently necessary to exclude this range in order for 386 enhanced mode to function properly. Most adapter cards are automatically detected and excluded by Windows 386 enhanced mode. If you suspect a problem with a 384K UMA memory conflict, use the EMMExclude= setting.
NOTE: If you suspect that your machine has multiple adapter mapping conflicts, it may be useful to exclude the entire UMA (A000-EFFF) for testing purposes.There are very few uses for the EMMInclude= setting. Normally Windows 3.1 386 enhanced mode automatically uses all free pages in the 384K UMA. Likewise, there are few uses for the EMMPageFrame= setting because it controls only the expanded memory page frame and not the translation buffers.
386 Enhanced Mode and Expanded MemoryWindows 386 enhanced mode does not use expanded memory itself. It can, however, create expanded memory for use by MS-DOS applications written to use expanded memory, such as Lotus 1-2-3 versions 2.x. Expanded memory required by an MS-DOS application can be specified in the application's program information file (PIF). It is no longer necessary for Windows applications to use expanded memory because they can now access extended memory directly. Thus, the main issues for expanded memory under Windows 3.1 are page frame conflicts, as discussed above. Windows 386 enhanced mode provides large page frame LIM 4.0 expanded memory in all virtual MS-DOS machines. Although this feature is not currently useful for most MS-DOS applications that use expanded memory- -they use only the LIM 3.2 64K page frame itself, not the additional bankable pages in conventional memory that large page frame LIM 4.0 supplies--it may be useful in the future. A compatible external 386 memory manager such as EMM386.EXE can be loaded to provide expanded memory for MS-DOS applications running outside Windows 386 enhanced mode. Such a memory manager is not needed for expanded memory to be available inside Windows 3.x, and is actually turned off when Windows 386 enhanced mode is run. See the "Expanded Memory for MS-DOS Applications" section of this application note for more information.
386 Enhanced Mode and Extended MemoryLike standard mode, Windows 386 enhanced mode can directly access extended memory. It adds free conventional memory and free extended memory plus virtual hard drive memory (the "swap" file). It then provides the total as memory for Windows applications to use (minus the memory required by 386 enhanced mode Windows itself). MS-DOS applications that use extended memory can also access extended memory in virtual machines under 386 enhanced mode Windows. The extended memory supplied to MS-DOS applications by Windows 3.1 386 enhanced mode can be virtualized.
Running Protected Mode MS-DOS ApplicationsWindows 386 enhanced mode allows MS-DOS applications to run in protected mode if they are written to use the DPMI specification. Windows 386 enhanced mode uses the XMS driver to load itself and its drivers into extended memory before starting up. This is why 386 enhanced mode requires the presence of HIMEM.SYS or another compatible XMS device driver. 386 Enhanced Mode and Virtual Memory: A Virtual Memory Conceptual Analysis Virtual memory allows you to simultaneously run more programs than the amount of physical memory installed on your computer would normally allow. Virtual memory has been widely used for years in the world of mainframe computers. Windows 386 enhanced mode offers virtual memory to the PC-compatible world by using the special demand paging capabilities of the Intel 80386 processor. All Windows programs can take advantage of virtual memory in Windows 386 enhanced mode. When you start Windows 386 enhanced mode, choose About Program Manager from the Help menu. You will see that much more memory is available than is installed on your machine. Windows applications can use this extra memory without being written specially for it because Windows applications are device independent; they let Windows handle the memory management and simply ask Windows for memory allocations. With virtual memory, Windows applications keep asking for more memory, which Windows 386 enhanced mode is now able to deliver. If you have less physical memory and are forced to rely on virtual memory, the application runs more slowly; if you have more physical memory, it runs more quickly--in either case, it is almost always able to run. While a program is running in virtual memory, at any given moment some parts of its code and data are in physical memory while the rest of the program is swapped to the hard disk. When a reference is made to a memory address, if the information is in physical memory, the information is used without program interruption. However, if the desired information is not in physical memory, a page fault occurs, and the Windows 386 enhanced mode virtual memory manager (VMM) takes control. The required code or data is pulled into physical memory from the hard disk, and if necessary, some other information is swapped out. Pages are swapped out on a least recently used (LRU) basis. The pages that have not been accessed for the longest time are the first to be swapped out. All this swapping is invisible to the user, who sees only a little hard disk activity. Windows 386 enhanced mode virtual memory brings pages of data into physical memory when they are referenced: this is called a demand- paged system. This system does not attempt to predict which pages will be required in the future. The 386 enhanced mode virtual memory subsystem is implemented by the Windows 3.x VMM and the page swap device. The VMM maintains the virtual memory page table; it lists which pages are currently in physical memory and which are swapped to disk. Because Windows 386 enhanced mode is a multitasking environment, the VMM page table also contains a list of which memory pages belong to which process. When the VMM needs a page that is not currently in physical memory, it calls the page swap device. The page swap device allocates and deallocates virtual memory and maps pages into and out of physical memory. Some virtual memory systems rely on program segmentation to do their work. Windows applications are segmented; however, virtual memory under Windows 386 enhanced mode is not related to the segmentation of Windows applications. All memory, virtual and physical, is divided into 4K pages, and the system is managed on this basis. Page mapping starts at zero K and works up. Two kinds of pages can be allocated: physical pages and virtual pages. The number of physical pages is simply the amount of physical memory in the machine divided by 4K. In contrast, memory allocated to an application is made up of virtual pages. At any given time, a virtual page can be in physical memory or swapped to the hard disk. As mentioned earlier, Windows 386 enhanced mode virtual memory management uses the LRU page-replacement algorithm. The virtual page table contains flags for each page that indicate whether the page has been "accessed" and if the page is "dirty." Accessed means that a process made a reference to the page after it was originally loaded. Dirty means that a write was made to the page after it was loaded. Because a memory write qualifies as an access, the dirty attribute implies the accessed attribute. To illustrate, assume Windows 386 enhanced mode is out of physical memory space. A process requests additional memory. Windows has to decide which pages currently in physical memory it should swap to disk to fulfill the request. This decision is a three-step process:
Virtual Memory Paging File Options and ControlsWindows 386 enhanced mode can use one of two types of virtual memory paging files, or swap files: temporary or permanent. Only one type of swap file can be used at a time when running Windows 3.1. Do not attempt to create a swap file on a RAM disk; this is a self-defeating pursuit--you would be sacrificing physical memory to provide a place to create virtual memory to replace the physical memory you have used to create the RAM disk. Windows 3.0 in 386 enhanced mode requires a minimum of approximately 1.5 MB of hard disk space free on the paging drive to provide virtual memory support with a temporary swap file. With Windows 3.1, that number is down to 512K. A temporary swap file is simply a normal MS-DOS file created on the hard disk that can shrink and grow in size as necessary. The temporary swap file is called WIN386.SWP, and it is created automatically when Windows 3.x is started. The swap file does not have a hidden or system attribute and can be deleted, if necessary, any time you are not running Windows, although it is normally deleted automatically when you exit Windows 386 enhanced mode. Temporary swap file location and size can be adjusted by inserting parameters in the [386enh] section of the SYSTEM.INI file. In Windows 3.0, the temporary swap file is always created in your Windows 3.0 directory unless you set the PagingDrive= setting. If the PagingDrive= setting is set (for example, PagingDrive=D:), the swap file will be created in the root directory of the specified drive. There is no way to specify a subdirectory for the temporary swap file location in Windows 3.0. In Windows 3.1, the drive and subdirectory of the temporary swap file may be specified with the PagingFile= setting. Temporary swap file size is controlled by the MaxPagingFileSize= setting. The size of the temporary swap file can also be limited in a different way by the use of the MinUserDiskSpace= setting, which tells 386 enhanced mode to leave the specified amount of disk space in kilobytes free when creating a temporary swap file. A permanent swap file occupies a contiguous section of your hard disk. Using a permanent swap file improves the speed of the Windows 3.x virtual memory system because there are fewer processor mode transitions and the swap file's access requires less overhead than a normal MS-DOS file. The permanent swap file is a hidden file called 386SPART.PAR, which also has a system attribute; the file is always placed in the root directory of the specified drive. Since the permanent swap file must be contiguous, you can't create one larger than the largest contiguous free segment of your hard disk. Permanent swap files are created and deleted by running SWAPFILE.EXE in Windows 3.0 real mode, or from the Windows 3.1 Control Panel by choosing the 386 Enhanced icon and then choosing the Virtual Memory button. A SYSTEM.INI file setting is not used to point to the location of the permanent swap file. Instead, when the permanent swap file is created, Windows creates a file called SPART.PAR in your Windows 3.x directory. Windows 386 enhanced mode reads the SPART.PAR file to find out where the permanent swap file is and how large it is. SPART.PAR is marked read-only to keep you from accidentally deleting it. If you delete SPART.PAR, Windows will not know about the permanent swap file and won't be able to make use of it. Because SWAPFILE.EXE and the Virtual Memory utility both read SPART.PAR, they cannot be used to delete the permanent swap file if SPART.PAR is deleted. If Control Panel (or SWAPFILE.EXE with Windows 3.0) says that the maximum swap file size it can create is smaller than your free disk space, your hard disk is fragmented. If you want to create a larger permanent swap file than Control Panel (or SWAPFILE.EXE) reports possible, you must optimize your hard disk (optimizing is also known as unfragmenting, or compacting). Optimizing must be done with a third-party utility program such as Bridgeway Publishing FastTrax, Norton Utilities, Mace Utilities, Golden Bow VOpt, or Central Point PC Tools. It is important to run these programs outside the Microsoft Windows environment. If you have already created a permanent swap file, make sure you delete it using Control Panel before optimizing your hard disk. It is not necessary to delete the permanent swap file every time you optimize your hard disk--only when you want to increase the size of the permanent swap file by optimizing, then re-creating it. The Virtual Memory utility supports only disks that use 512-byte sectors for the swap file. If 512-byte sectors are not being used, this indicates a non-standard configuration such as a third-party disk partitioning driver. The Virtual Memory utility (and Windows 3.x itself) supports drives with 512-byte sectors that have been partitioned with the MS-DOS fdisk command. (NOTE: Certain OEM versions of MS-DOS have altered versions of fdisk that will partition drives using sector sizes other than 512 bytes.) Never run the Virtual Memory utility on a drive that uses a partitioning driver in the CONFIG.SYS file, with the exception of Compaq's ENHDISK.SYS. If you receive a message that your swap file is corrupted, use Control Panel (or SWAPFILE.EXE in Windows 3.0) to delete the corrupted swap file and create a new one.
Paging to Network DrivesPaging to a network drive, while certainly possible, is extremely slow and is not recommended. Only temporary swap files can be used on network drives. If you want to page to a network drive, the directory must not have an MS-DOS read-only attribute; you must have create and write access to the directory.
NOTE: Because the root of a Novell network drive is the root of the server, it is not MSNet-Redirector compatible. Do not set the PagingDrive= setting to a Novell network drive. If you do so and multiple users run Windows 3.1 386 enhanced mode, their computers will hang because they will overwrite each other's swap files, all with the same name and all created in the root directory of the server. WIN.COM AUTOMATIC STARTUP PARAMETERSWIN.COM starts up automatically in the appropriate operating mode for your machine and the amount of memory installed. Operating modes are real mode (similar to Windows/286 2.x), which is only available in Windows 3.0; 286 standard mode (also known as 286 protected mode); and 386 enhanced mode (also known as 386 protected mode). However, Windows may be forced into any of the modes through the following command-line switches (provided the mode is supported by your hardware):
Command Line Mode ----------------------------------------------- win /r Real (Windows 3.0 only) win /s or win /2 Standard win /3 386 enhanced Real Mode RequirementsThe requirements for WIN.COM to automatically start up in real mode are the following: - Windows 3.0 - 8088 processor or above - 384K of free conventional memory (393,216 bytes reported by chkdsk)Standard Mode RequirementsThe requirements for WIN.COM to automatically start up in standard mode are the following: - 80286 processor or above - 192K of free extended memory - XMS driver loaded (HIMEM.SYS)
Practical Standard Mode RequirementsStandard mode conventional/extended memory requirements are mutually dependent and are not fixed. A typical installation requires a minimum of 128K of memory free at the MS-DOS prompt to run standard mode, assuming sufficient extended memory is free. Standard mode requires between 384K and 512K of combined conventional and extended memory to run (approximately). For example, if only the minimum 192K of extended memory is free, approximately 322K of conventional memory is required to run standard mode. However, if available extended memory is increased to approximately 208K or greater, only 128K of conventional memory is required.
386 Enhanced Mode RequirementsThe requirements for WIN.COM to automatically start up in 386 enhanced mode are the following:
Practical 386 Enhanced Mode RequirementsSee the above notes for standard mode regarding the interrelationship of conventional and extended memory requirements. A typical installation requires a minimum of 182K of memory free at the MS-DOS prompt to run 386 enhanced mode, assuming sufficient extended memory is free. Windows 386 enhanced mode requires between 580K and 624K combined conventional and extended memory to run (approximately).
NOTE: 386 enhanced mode can start up in low memory situations because it provides virtual memory support; however, it may be extremely slow due to the large amount of disk swapping it must perform.All numbers are approximate and may vary widely depending on the configuration (for example, Windows device drivers chosen, MS-DOS version, display adapter, and so on). 128K of extended memory is recovered from shadow RAM usage on COMPAQ 386 machines. Memory requirements take into account memory that can be recovered from SMARTDrive (down to the minimum cache size specified).
THE FREE SYSTEM RESOURCES PERCENTAGEThe Program Manager and File Manager About boxes in the Help menus of Windows 3.1's standard and 386 enhanced modes give percentage figures for free system resources and free memory. In Windows 3.0, these figures can be obtained from the About box of the Program Manager Help menu. To understand what the free system resources percentage means, you must understand some of the anatomy of Windows's internal structure. The part of Windows that runs Windows applications is made up of three main segments called KERNEL, GDI (graphics device interface), and USER. KERNEL loads and runs Windows applications and handles their memory management. GDI manages graphics and printing. USER controls user input and output, including the keyboard, mouse, sound driver, timer, and communications ports. These three segments exist as separate .EXE files and are located in the WINDOWS\SYSTEM subdirectory. GDI has a storage area limited to 64K, which is known as a local heap. Currently, USER has two such areas, hence 128K storage. The free system resources percentage reflects the remaining free percentage of USER or GDI local heap space, whichever is lower. Although Windows 3.1 allows you to run a much larger number of simultaneous Windows applications than any previous Windows version, like Windows 3.0, it is not without limitations. If you receive an "Out of memory" error and the Help About box shows a large amount of free memory, look at the free system resources percentage. Chances are you are low on system resources. Every window and icon that is created requires USER local heap space. It is theoretically possible to exhaust the system resources with only one application, such as Program Manager, if enough objects are created by the application. Another important aspect of Windows application memory management that is not included in the free system resources percentage is the number of selectors. A selector is a memory pointer that is consumed with each memory allocation made by a Windows application. Windows 3.1 has a fixed number of selectors (4096 in standard mode, 8192 in 386 enhanced mode). If a Windows application allocates a very large number of small data objects, it is possible to run out of selectors. This will also produce an "Out of memory" error message. Writing a Windows application to handle its own data objects more efficiently can help in this situation. If you experience a chronic problem with a particular application while few or no other applications are loaded, contact the application vendor. It is important that the vendor become aware of the problem so it can be corrected if possible. Writing an application to handle data objects more efficiently can help reduce "Out of memory" conditions.
386 ENHANCED MODE PERFORMANCE TIPS: GETTING THE MOST FROM YOUR MACHINEThe following suggestions should assist you in maximizing the performance of your Windows 386 enhanced mode installation. Many of these suggestions apply to standard and real modes as well.
EXPANDED MEMORY FOR MS-DOS APPLICATIONS
Under Real Mode Windows 3.0Real mode Windows 3.0 and MS-DOS applications can both use the same external expanded memory manager (EMM). Expanded memory can be provided either by a physical expanded memory board, or by a 386 EMM. Common expanded memory boards include the AST RAMpage! and Intel Above Board. Common 386 EMMs include Microsoft's EMM386.SYS (included with Windows), Compaq's CEMM.EXE (included with COMPAQ 386 machines), Qualitas's 386 to the Max (386MAX.SYS), and Quarterdeck's QEMM.SYS. If a physical expanded memory board is used, you will get the best performance from real mode Windows by backfilling to provide large page frame LIM 4.0 support. Some boards do not have the hardware register support to provide large page frame LIM 4.0--only small page frame (see "Expanded Memory" section of this application note). All 386 EMMs provide large page frame LIM 4.0 support. Remember that MS-DOS applications require LIM 3.2 (a 64K contiguous page frame) to use expanded memory, but real mode Windows requires LIM 4.0 (does not require a 64K contiguous page frame). If you see expanded memory in Windows but not in your MS-DOS applications, you probably do not have a 64K contiguous page frame (LIM 3.2), and you may need to rearrange adapter locations. For more information, see "Expanded Memory" section of this application note.
Under Standard Mode Windows 3.xAs noted in the "Standard Mode and Conventional Memory" section of this application note, Windows 3.x standard mode does not use expanded memory. MS-DOS applications running under standard mode can use expanded memory only with a physical expanded memory board such as an AST RAMpage! or Intel Above Board. You cannot use 386 EMMs to provide expanded memory support for MS-DOS applications running under standard mode. Still, 386-compatible EMMs can be loaded to provide MS-DOS- application expanded memory support outside standard mode in Windows 3.1. Such EMMs cannot be used in conjunction with standard mode Windows 3.0.
Under 386 Enhanced Mode Windows 3.xExpanded memory emulation is provided internally for MS-DOS applications running under 386 enhanced mode. The only requirement is the presence of a 64K contiguous page frame for LIM 3.2 compatibility. For more information on page frame placement, see the "386 Enhanced Mode and the 384K Upper Memory Area (UMA)" section of this application note. Expanded memory for MS-DOS applications can be allocated and/or limited through PIF settings.
External 386 Expanded Memory ManagersSome 386 EMMs have a special feature that allows standard or 386 enhanced mode Windows to turn them off when Windows is run. Memory managers with this capability are EMM386.EXE and CEMM.EXE. Windows can turn off EMM386.EXE even if expanded memory is in use at the time. CEMM.EXE requires that no expanded memory be in use when standard or 386 enhanced mode Windows is run. Some 386 EMMs provide the capability of loading MS-DOS device drivers into free areas of the 384K UMA. CEMM.EXE does not provide this capability, but the combination of MS-DOS 5.0 and EMM386.EXE, or 386MAX.SYS and QEMM386.SYS does.
DPMI AND VCPI
Specifications for Different PurposesThe MS-DOS Protected Mode Interface (DPMI) was developed by a group of industry leaders including Borland, Eclipse, IBM, IGC, Intel, Locus, Lotus, Microsoft, Phar Lap, Quarterdeck, and Rational Systems. Several members of the DPMI committee were also involved in the creation of the Virtual Control Program Interface (VCPI). DPMI is primarily a creation of Microsoft, and VCPI was formulated primarily by Phar Lap Software.
MS-DOS Extended ApplicationsMS-DOS extended applications execute code in the protected mode of the 80286 or 80386 processor. Unlike OS/2 applications, MS-DOS extended applications are launched from standard MS-DOS. Creating an MS-DOS extended application requires a method to switch the processor to protected mode and to allocate extended memory. Until DPMI, there was no standard method for MS-DOS extended applications to perform these tasks and multitask memory with other applications on 80286 processors. Hundreds of existing applications have been created using various types of MS-DOS extenders. OS/2 extender applications that do not already support DPMI will require minor modifications to do so.
Comparing VCPI to DPMIVCPI and DPMI solve two different problems. VCPI provides an interface between applications using MS-DOS extenders on an 80386 machine and 386 EMMs. For example, the 386 EMMs (EMM386.EXE, QEMM.EXE, 386MAX.EXE, and CEMM.EXE) support the VCPI specification. VCPI allows applications using MS-DOS extenders to run simultaneously with 386 EMMs on a 386 machine. However, multitasking operating environments such as Windows 386 enhanced mode, OS/2, UNIX 386, and VM386 have memory and protection models that are not compatible with the VCPI interface. DPMI was created so these environments can run extended MS-DOS applications. Additionally, DPMI provides support for 80286-based machines, while VCPI does not. DPMI has the capability of running MS-DOS extended applications on a variety of processors and operating environments.
GLOSSARY
386 Expanded Memory Manager (EMM)A device driver loaded that provides expanded memory on an 80386-based computer without a physical expanded memory board. 386 expanded memory managers (EMMs) operate through the 80386 processor's hardware capabilities.
386MAX.SYSA 386 expanded memory manager (EMM) from Qualitas Corporation.
CEMM.EXEA 386 EMM from Compaq. CEMM is provided with all Compaq 386-based computers. It has an extension of .EXE rather than .SYS, even though it is installed in the CONFIG.SYS file like other 386 EMMs.
Conventional MemoryThe memory in your machine from zero K to 640K.
DPMIThe MS-DOS Protected Mode Interface (MS-DOS extender industry standard). Applications that use the DPMI specification can run in protected mode and break the 640K barrier under standard or 386 enhanced mode. The DPMI specification is available from Intel Corporation.
EMM386.EXEThe Microsoft 386 expanded memory manager (EMM). See the "Microsoft Windows 3.1 User's Guide" for more information.
EMMExpanded memory manager.
EMSExpanded Memory Specification.
Expanded Memory Specification (EMS)There are two expanded memory specifications, which are designated LIM 3.2 and LIM 4.0.
Expanded Memory Manager (EMM)A device driver that provides an interface to expanded memory. An expanded memory manager, or EMM, is either specific to a particular physical expanded memory board, or uses the 386 processor.
Extended MemoryMemory in your machine above 1 MB. Extended memory always starts at 1024K.
Extended Memory Specification (XMS)The XMS provides a standard way for real mode applications to access extended memory. MS-DOS applications running under Windows 3.x can use the XMS to access extended memory. The XMS document and sample source code is available from Microsoft Sales Information Center (MSIC) at (800) 426-9400.
HIMEM.SYSMicrosoft's high memory manager. Manages extended memory in accordance with the Extended Memory Specification (XMS).
Large Page FrameA slang term denoting the presence of bankable expanded memory pages in conventional memory. Large page frame is usually used to refer to a number of bankable pages equal to or greater than 384K (that is, bankable pages ranging from 256K to 640K). Note that the term "large page frame" is a misnomer. The page frame is actually never any larger than four 16K pages and is always located in the 384K UMA. Additional bankable pages in conventional memory do not make the page frame larger; they simply provide additional bankable pages.
LIM 3.2The Lotus/Intel/Microsoft Expanded Memory Specification (EMS) version 3.2. It provides for a maximum of four 16K bankable pages that must be contiguous.
LIM 4.0The Lotus/Intel/Microsoft Expanded Memory Specification (EMS) version 4.0. It provides for a maximum of 64 16K bankable pages that do not have to be contiguous.
Page FrameAn area within the 384K upper memory area (UMA) that is designated the expanded memory page frame. The page frame itself can be a maximum of four 16K pages.
QEMM386.SYSA 386 expanded memory manager (EMM) by Quarterdeck Office Systems.
Small Page FrameA slang term denoting the presence of expanded memory that does not place bankable pages within conventional memory.
UMAUpper memory area.
Upper Memory Area (UMA)The area between 640K and 1024K present on all IBM-compatible machines. Sometimes called the reserved address space because this area was originally reserved by IBM for the ROM BIOS, video memory, and other hardware functions.
VCPIVirtual Control Program Interface. An 80386 memory management standard created by Phar Lap Software in conjunction with other software developers.
VMVirtual (8086) machine. The VM exists in a protected memory space created through the hardware capabilities of the 80386 processor.
Virtual MemoryThe space on a hard drive partition that 386 enhanced mode Windows can address as physical memory. Often referred to as the (temporary or permanent) "swap" file.
VMMVirtual memory manager.
Virtual Memory Manager (VMM)Manages the disk space used as virtual memory.
XMSExtended Memory Specification.
TO OBTAIN THIS APPLICATION NOTE
You can find WW0335.EXE (size: 37445 bytes) , a self-extracting file, on the followingservices:
ARTICLE-ID: Q119591 TITLE : How to Obtain Microsoft Support Files from Online Services
|
KBCategory: kbfile kbenv kbhw kbappnote
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |