Virtual address space of a process
Each process is assigned its own virtual address space. For a 3-2-bit process, the address space is 4g B, because 3 2-bit pointers can have any value from 0x0 0 0 0 0 0 0 0 to 0 x f. This allows a pointer to have a value of 4 294 967 296 values, which covers the range of 4g B virtual space of a process.
Since each process can receive its own private address space, when a thread in the process is running, the thread can access the memory of its only process. Memory of all other processes is hidden and cannot be accessed by running threads. Note: in Windows 2000, the memory of the operating system itself is also hidden, and the running thread cannot be accessed. This means that the thread often cannot access the data of the operating system.
The virtual address space of each process must be divided into various partitions. The address space partition is based on the basic implementation method of the operating system. The partitions of different wi n d o w s kernels are also slightly different. Table 1 3-1 shows how each platform partitions the address space of a process.
Table 13-1 partitions the address space of a process
| Partition |
32-bit Windows 2000 (x86 and Alpha processors) |
32-bit Windows 2000 (x86w/3 GB user mode) |
64-bit Windows 2000 (alpha and IA-64 processors) |
Windows 98 |
| Partition allocated by n u l pointer |
0x0 0 0 0 0 0 0 0x0 0 0 f |
0x0 0 0 0 0 0 0 0x0 0 0 f |
0x00000000 00000000 0x00000000 0000 FFFF |
0x0 0 0 0 0 0 0 0x0 0 0 0 f |
| DOS/16-bit windows application compatible Partition |
None |
None |
None |
0x0 0 0 0 1 0 0 0x0 3 f |
| User Mode |
0x0 0 0 1 0 0 0 0x7 f e f |
0x0 0 0 1 0 0 0 0 0 x B f e f |
0x00000000 00010000 0x000003ff fffeffff |
0x0 0 4 0 0 0 0 0x7 f |
| 64-kb |
0x7 f 0 0 0 0 |
0 x B f 0 0 0 0 |
0x0 0 0 0 3 f 0 0 0 0 |
None |
| Forbidden |
0x7 f |
0 x B f |
0x0 0 0 0 3 f |
None |
| Shared Memory ing |
None |
None |
None |
0x8 0 0 0 0 0 0 0 |
| File (MMF) Kernel Mode |
0x8 0 0 0 0 0 0 0 0 x f |
0 x C 0 0 0 0 0 0 0 x f |
0x00000400 00000000 0 xfffffffff fffffff |
0 x B f 0 x C 0 0 0 0 0 0 0 0 x f |
Null Pointer: It is null in the program. the partition of the process address space is set to help the programmer understand the allocation of n u l pointers.
MS-DOS/16-bit windows application compatible partition-only for Windows 98: This 4 m B partition of the process address space is required by Windows 98, the purpose is to maintain the compatibility between the MS-d o s application and one 6-bit application.
User Mode: This partition is where the private (non-shared) address space of the process is located. A process cannot read, write, or access data of another process residing in the Partition in any way. For all applications, this partition is the place where most data of the process is maintained. Since each process can obtain its own private, non-shared partition to store its data, the application is unlikely to be damaged by other applications, this makes the entire system more robust. The system can also map all memory ing files that the process can access in this partition. When I first observed the address space of three or two processes, I was surprised to find that the available address space was less than half of the total address space of my process. Does kernel-based partitioning really require half of the above address space? In fact, the answer is yes. The system needs this address space for kernel code, device driver code, device I/O cache, non-page memory pool allocation, and process page tables. In fact, m I c r o s o f t compresses the kernel into this 2g B space.
64 kB prohibited partition-only applicable to Windows 2000: the 64 kB partition located on the user-mode partition is forbidden to access. Any attempt to access the memory in the partition will result in access violations. M I c r o s o f t retains the partition because it makes it easier for m I c r o s o f t to implement the operating system. When the address and length of the memory block are passed to the WI n d o w s function, this function will make the memory block take effect before executing its operation.
Shared MMF partition-for Windows 98 only: This 1g B partition is used by the system to store the data shared by all three 2-bit processes. For example, the system's dynamic link library k e r n e L 3 2. d l, a d v a p I 3 2. d l, u s e r 3 2. d l and G d I 3 2. d l and so on are all stored in this address space partition. Therefore, all three 2-bit processes can easily access them at the same time.
Kernel partitioning-applicable to Windows 2000 and Windows 98: This partition stores the operating system code. Code for thread scheduling, memory management, file system support, network support, and all device drivers are loaded in this partition. Everything that resides in this partition can be shared by all processes. In Windows 2000, these components are completely protected.
Region in the address space
When a process is created and assigned an address space, the subject of the available address space is idle, that is, it is not allocated. To use each part of the address space, you must call the vi r t u a l o C function (chapter 5 of Chapter 1st) to allocate each area of the address space. The operation for allocating an address space area is called reservation (r e s e r v I n g ).
Whenever you reserve an area of the address space, the system must ensure that the area starts from a boundary of allocation granularity. For different c p u platforms, the allocation granularity varies.
Submit the physical storage in the address space area
To use a reserved address space area, you must allocate a physical storage and map it to the reserved address space area. This process is called commit physical storage. Physical storage is always submitted in the form of pages. To submit the physical storage to a reserved address space area, call the vi r t u a l o C function.
Physical storage and page files
In older operating systems, physical memory is considered as the r a m Capacity owned by computers. In other words, if the computer has a r a m of 1 6 m B, then the load and run applications can use a r a m of 1 6 m B at most. Today's operating system makes the disk space look like memory. A file on a disk is usually called a page file, which contains the virtual memory that can be used by all processes.
Of course, to make the virtual memory run, you need a lot of help from the c p u itself. When a thread tries to access the memory of a byte, the c p u must know whether the byte is in r a m or on the disk.
From the application perspective, page files transparently increase the number of r a m (memory) available to applications. If the computer has 6 4 m B R A m, and there is a 100 MB page file on the hard disk, then the running application assumes that the computer has a total of 1 6 4 m B R A M.
Of course, the r a m does not actually own 1 6 4 m B. On the contrary, the operating system is coordinated with c p u to save each part of r a m to a page file. When the running application needs, then, load all the parts of the page file to r a m. Because the page file increases the r a m capacity available for the application, the use of the page file depends on the situation. If there is no page file, the system considers that only a small number of r a m files can be used by applications. However, we encourage users to use page files so that they can run more applications that can operate on larger datasets. It is better to treat physical storage as data stored in page files on a disk drive (usually hard drive. In this way, when an application calls the vi r t u a l o C function and submits the physical memory to a region of the address space, the address space is actually allocated from a file on the hard disk. The size of the page file of the system is the most important factor to consider when determining how much physical memory is available for use by applications. The size of r a m has a very small impact.
Importance of Data Alignment
When the c p u accesses the correct aligned data, it runs most efficiently. When the memory address of the Data modulus is 0, the data is aligned. For example, the w o r d value should always start from the address divided by 2, and the d w o r d value should always start from the address divided by 4. When the data values that c p u tries to read are not correctly aligned, c p u can perform either of the two operations. That is, it can generate an exception condition or execute multiple alignment memory accesses to read the complete alignment data values.