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