How to manage Windows Memory: page management, segment management, section-to-page management
Page-style management
The virtual space (logical address) of each process is divided into several pages of equal length, the industry manages to divide the memory space (physical memory) into slices or pages according to the size of the page, thus realizing the discrete allocation, then the page virtual address and memory address to establish one by one corresponding page table, and the corresponding hardware address transformation mechanism to solve the problem of discrete address change (when the program loads, you can put any page in memory any page box and these page boxes do not need to be contiguous, thus realizing the discrete allocation) page management using the request paging or pre-paging technology to achieve the unified management of internal and external storage memory, The address structure consists of two parts, the page number + the address inside the page
The advantage is that there is no outer fragment, and each inner fragment does not exceed the size of the page. Each program does not need to be stored continuously, so that it is easy to change the size of the program footprint (mainly with the program running, the dynamic generation of data increased, the required address space to grow correspondingly), the disadvantage is that the program is still loaded into memory, to have the corresponding hardware support, For example, the generation of page breaks for address translation agencies and the selection of obsolete pages require corresponding hardware support, which increases the cost of the machine, increases the overhead, and does not have enough memory for the program to execute
Segment-Type management
The program according to the content and process function relationship segmentation, each paragraph has its own name, a user job or process includes a two-dimensional linear virtual space, that is, a two-dimensional virtual memory, segment management program to allocate memory as a unit, and then through the address mapping mechanism to convert the segment virtual address to the actual memory address. Advantages: You can write and compile separately, you can use different protection for different types of segments, you can share by segment and then use dynamic link for code sharing. The disadvantage is that it produces fragments
Section-page Management
For the purpose of section-page management, the system must establish a segment table for each job or process to manage memory allocation and deallocation, missing segment processing. In addition, since a segment is divided into pages, each segment must create a page table in which the virtual pages in the segment are transformed into the actual pages in memory. Obviously, the same as page management, the page table should also have a corresponding page to interrupt the pages to deal with the protection of the Table entries, section page management and page management of the combination of management solutions with the advantages of both, but on the other hand because of the increase in management software, complexity and overhead increases, Additional hardware and memory usage also increased, slowing down the speed of the drive.
What is the difference between a page and a paragraph?
Similarity: Discrete allocation, address mapping mechanism to implement address translation
(1) The page is the physical unit of information, paging is to achieve discrete distribution, reduce the amount of memory, improve memory utilization, or because of the needs of the system management, rather than the needs of users. Paragraph is the logical unit of information, it contains a set of relatively complete information, the purpose of segmentation is to better meet the needs of users.
(2) page size fixed and determined by the system, the logical address divided into the page number and the page address two parts, is the machine hardware implementation, the length of the segment is not fixed, but decided by the user to write the program, usually by the compilation system in the source program compiled according to the nature of the information to divide
(3) The system address in the page is one-dimensional, that is, a single linear address space, the programmer can only use an identifier to represent an address. The job address space of the segment is two-dimensional, and the programmer needs to give the segment name when identifying an address, and the address in the segment
How Windows memory manages and pros and cons