Windowss core programming-Windows Memory Structure

Source: Internet
Author: User
1. Areas in the address space:

When a process is created and allocated space, the available address space subject is idle, that is, not allocated. To use space, you can use the virtualalloc function to allocate all its regions. Windows has a granularity boundary. The system allocates a region at the granularity of 64 KB.

In addition, the system management memory also has a unit granularity, that is, the page that is often mentioned, the page size is 4 kb in x86, In the virtual memory of the operating system, the page replacement function (that is, transferring data from the hard disk (Virtual Memory) to the memory) is executed on pages.

For example, if you want to retain a 10 KB address space area, the system will automatically round your request so that the size of the reserved address space area is a multiple of the page size. This means that on the x 8 6 platform, the system will retain a region of 1 2 k B.

When you no longer need a space area, you only need to use the virtualfree function to release it.

2. Physical storage and page files:

When a thread in a process accesses a data block in its address space, two situations occur:

In the first case, the data that the thread tries to access is in r a m. In this case, c p u maps the virtual memory address of the data to the physical address of the memory, and then executes the required access.
In the second case, the data that the thread tries to access is not in r a m, but is stored somewhere in the page file. In this case, the attempt to access is called a page failure, and the c p u will notify the operating system of the attempt. Then, the operating system looks for a blank Memory Page in r a m. If no blank page is found, the system must release an empty page. If a page has not been modified, the page can be released. However, if the system needs to release a modified page, it must first copy the page from r a m to the page swap file, and then the system enters the page file, find the data block to be accessed and load the data to the idle Memory Page. Then, the virtual memory address updated by the operating system to indicate the data has now been mapped to the table in the corresponding physical memory address in r a m. At this time, c p u re-runs the command to generate the initial Page failure, but this time, c p u can map the virtual memory address to a physical r a m address and access the data block.

Into

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.