7-Windows core programming-partition of memory in Windows 2000

Source: Internet
Author: User
Note: This article only involves Windows 2000, not Win98. For Win98, memory partitions are significantly different from those of 2000.

1. Virtual Address Space of the process
32-bit ApplicationProgramThe virtual address space of the process is available in 4 GB memory. Because the 32-bit pointer can represent the addresses from 0x00000000 to 0xffffffff.
Each thread in a process can access the memory in its own process. Memory of other processes is hidden from the thread and cannot be accessed!
Another piece of memory is hidden, that is, the memory occupied by the operating system. The thread cannot access the data of the operating system. However, this is an exception for Win98.
The virtual memory space is not the actual memory address. The actual memory address mapped to the virtual address 0x12345678 in process A is not the actual memory mapped to the virtual address 0x12345678 in process B, although their virtual address values are the same.
Therefore, in Win32, the actual memory is mapped!
In addition, not all 4 GB virtual address spaces can be accessed. Specifically, it depends on whether the memory is mapped. If yes, it can be accessed. If not, the access data is in violation.

2. partitions in the virtual memory
Partitioning is to classify different data into different data areas. What are the categories?
(1) Null Pointer area: 0x000000000000-0x0000ffff
It is the area where NULL pointers are stored. Its address space is 64 K.
The 64 KB data read by the thread is illegally accessed. Therefore, we understand why we need to perform a null pointer check for C ++, and sometimes access is not checked, just like below Code As shown in: Int * Pnsomeinteger = ( Int * ) Malloc ( Sizeof ( Int ));
* Pnsomeinteger =   5 ;

If the above memory allocation fails, malloc returns NULL, and the following operation will violate the rules.

(2)User method: 0x0000000-0x7ffeffff
This is where the private code and data of the process are stored. In addition, the process cannot operate the data in the memory of the process. In this way, the application is unlikely to be damaged by other programs, making the system more robust.
This memory is also the memory area that our program can use. The size is less than 2 GB. The remaining 2 GB is empty for the kernel address space.

(3)64kb access zone: 0x7fff00000-0x7fffffff
It is also the area that the thread cannot access. Why do we create this area? The book says that m I c r o s o f t retains this partition, this will make 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.
A little hard to understand? Yes?

(4) kernel partitioning: 0x80000000-0xffffffff
stores the Operating System code for thread scheduling, memory management, and file system support, network Support and drivers for all devices.
data residing here can be shared by all processes.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.