Chapter 4: Memory Management
35
the segmented memory model is no longer attractive. Whatever the reason,
Microsoft decided to do away with the segmented memory model with Windows
NT. The programmer need not worry whether the code/data fits in 64K segments.
With the segmented memory model becoming extinct, the programmer can breathe
freely. At last, there is a single memory model, the 32-bit flat address space.
Windows NT is a protected operating system; that is, the behavior (or misbehav-
ior) of one process should not affect another process. This requires that no two
processes are able to see each other's address space. Thus, Windows NT should pro-
vide each process with a separate address space. Out of this 4GB address space
available to each process, Windows NT reserves the upper 2GB as kernel address
space and the lower 2GB as user address space, which holds the user-mode code
and data. The entire address space is not separate for each process. The kernel code
and kernel data space (the upper 2GB) is common for all processes; that is, the ker-
nel-mode address space is shared by all processes. The kernel-mode address space is
protected from being accessed by user-mode code. The system DLLs (for example,
KERNEL32.DLL, USER32.DLL, and so on) and other DLLs are mapped in user-mode
space. It is inefficient to have a separate copy of a DLL for each process. Hence, all
processes using the DLL or executable module share the DLL code and incidentally
the executable module code. Such a shared code region is protected from being
modified because a process modifying shared code can adversely affect other
processes using the code.
Sharing of the kernel address space and the DLL code can be called implicit shar-
ing. Sometimes two processes need to share data explicitly. Windows NT enables ex-
plicit sharing of address space through memory-mapped files. A developer can map
a named file onto some address space, and further accesses to this memory area are
transparently directed to the underlying file. If two or more processes want to share
some data, they can map the same file in their respective address spaces. To simply
share memory between processes, no file needs to be created on the hard disk.
Below the Operating System
In her book Inside Windows NT, Helen Custer discusses memory management in the
context of the MIPS processor. Considering that a large number of the readers
would be interested in a similar discussion that focuses on Intel processors, we dis-
cuss the topic in the context of the Intel 80386 processor (whose memory manage-
ment architecture is mimicked by the later 80486 and Pentium series). If you are
already conversant with the memory management features of the 80386 processor,
you may skip this section entirely.
We now examine the 80386's addressing capabilities and the fit that Windows
NT memory management provides for it. Intel 80386 is a 32-bit processor; this im-
plies that the address bus is 32-bit wide, and the default data size is as well. Hence,
4GB (2
32
bytes) of physical RAM can be addressed by the microprocessor. The
microprocessor supports segmentation as well as paging. To access a memory
Previous Main Next