Article ID: 125691 - View products that this article applies to.
This article was previously published under Q125691
This article has been archived. It is offered "as is" and will no longer be updated.
The virtual memory management mechanism in Microsoft Windows 95 makes it possible to execute Win32-based, 16-bit-based, and MS-DOS-based applications simultaneously. To accomplish this, the virtual memory manager uses a virtual address space layout that is considerably different from that used by Microsoft Windows version 3.x and that is slightly different from that used by Microsoft Windows NT. Although the differences from Windows NT are slight, they are important.
The memory manager in Windows 95 uses paging and 32-bit linear addressing to provide a full 32-bit virtual address space that has a maximum size of four gigabytes (GB). This four-GB address space is partitioned by the memory manager into four major sections, known as arenas, that are used for different types of applications and parts of the system. The first arena, from zero to four megabytes (MB) exists for compatibility with applications based on Windows version 3.1x and MS-DOS. The next arena, from four MB to two GB, is the private address space for each Win32 process. The third arena, from two to three GB, is a shared address space that contains memory mapped files and the 16-bit components. Finally, the fourth arena, from three to four GB, is reserved for the system's use.
The following diagram shows the overall virtual address space layout used in Windows 95. The Compatibility Arena holds the current virtual machine and other software. Each Win32 process gets its own private address space in which to execute. The Private Arena contains the currently executing Win32 process's private address space. All 16-bit-based applications and DLLs, including the 16-bit Windows system components, reside in the Shared Arena. Finally, the Reserved System Arena is used to store all ring-0 code such as the virtual machine manager and virtual device drivers. It is not accessible by either 16-bit-based or Win32-based applications.
+---------------------------------+ 4 Gigabytes | | | Reserved System Arena | | (Holds ring-0 components) | | | |---------------------------------| 3 Gigabytes | | | Shared Arena | | | | | |---------------------------------| 2 Gigabytes | | | Private Arena | | (Holds address space of | | currently executing | | Win32 process) | | | +---------------------------------+ 4 Megabytes | 16-bit/MS-DOS | | Compatibility Arena | +---------------------------------+ 0 Gigabytes
Each arena has a specific purpose and is described in detail below.
16-bit/MS-DOS Compatibility Arena
The first four megabytes of the system's address space is reserved by the system and is accessible to 16-bit and MS-DOS software for compatibility. The current virtual machine occupies the lowest megabyte of this area. The remaining three megabytes are mostly empty space but may contain MS-DOS device drivers and Terminate & Stay Resident (TSR) programs.
The 16-bt/MS-DOS Compatibility Arena is not accessible to Win32 processes for reading or writing. This means Win32 processes may may not allocate memory, load DLLs, or be loaded below the four megabyte (MB) address.
The private arena holds the private address space of the currently executing Win32 process. Because every Win32 process gets its own address space, the contents of this arena will depend upon which process is currently executing. The memory manager maps the pages of a process's private address space so that other processes cannot access it and corrupt the process. The process's code, data, and dynamically-allocated memory all exist in the private address space.
With the exception of the system's shared DLLs (USER32.DLL, GDI32.DLL, and KERNEL32.DLL), all DLLs loaded by the process are mapped into the process's private address space. Windows extension DLLs such as SHELL32.DLL, COMCTL32.DLL, and COMDLG32.DLL are not system shared DLLs and are mapped into the process's private address space.
Because console applications are Win32-based applications without graphical user interfaces, they too get their own private address spaces, as do Win32 graphical user interface (GUI) applications.
The minimum load address for a Win32 process in Windows 95 is four MB because the first four megabytes are reserved for the Compatibility Arena.
The shared arena is unique to Windows 95. This arena contains components that must be mapped into every process's address space. All of the pages in this arena are mapped identically in every process.
The 16-bit global heap, which contains all 16-bit-based applications, DLLs, and 16-bit system DLLs, resides in the shared arena. The Win32 shared system DLLs (USER32.DLL, GDI32.DLL, and KERNEL32.DLL) are also located in the shared arena.
Unlike the Reserved System Arena, the shared arena is readable and writable by Win32 and 16-bit processes alike. This doesn't mean they are free to get memory directly from this address space. All 16-bit-based applications and DLLs actually are located in the 16-bit global heap, so they allocate memory from the 16-bit global heap; when this heap needs to be grown, KRNL386.EXE gets the memory from the shared arena.
Win32 processes may not allocate memory directly from the shared arena, but they always use it for mapping views of file mappings. Unlike Windows NT, where views of file mappings always are placed in the private address space, Windows 95 holds views of file mappings in the shared arena.
The DOS Protected Mode Interface (DPMI) server's memory pool is located in the Shared Arena. Thus, calls to the DPMI server to allocate memory will result in memory that is globally accessible.
Sometimes, a virtual device driver (VxD) may need to map a buffer passed to it by a Win32 process into globally accessible memory so that the buffer can be accessed even if the process isn't in context. By calling _LinPageLock virtual machine manager service with the PAGEMAPGLOBAL flag, a VxD can obtain a linear address in the shared arena that corresponds to the buffer passed to it by the Win32 process.
Reserved System Arena
The reserved system contains the code and data of all ring-0 components such as the virtual machine manager, DOS extender, DPMI server, and virtual device drivers. This arena is used exclusively by ring-0 components and not addressable by ring 3 code, such as MS-DOS-based, 16-bit-based, and Win32-based applications and DLLs.