Linux Source Code Read Note - Memory Management

xiaoxiao2021-03-05  31

1. Memory Management 1. Summary In order to be compatible with the Intel 8086 implementation, continue to keep the segment address mode. Segment address mode uses several critical segment registers, such as: CS, DS, SS, ES, adds FS, GS in 80386 mode. These segment registers differ in the protection mode in the real mode, in the protection mode, as the following table for GDT (global description table), in the protection mode, segment description is stored in the description of the form, and the address is saved. In the GDTR register of the CPU, this is determined in the kernel initialization. The segment corresponds to the domain mm in the PID in the memory, and the memory address is defined in the 80386, a weight is a segment mapping, from the logical address to the linear address, and the other is a page map, from the linear address to the physical address. These two returns are completed by hardware circuits within the CPU, and the speed is very fast. These two returns provide my myopia's same memory protection, and Linux uses more page mappings. In response to: Physical memory management with pages (page size is 4K or 4M), page can improve the efficiency of memory, page size fixed, is an integer multiple of the size of the disk block, which is conducive to solving the problem of virtual memory, Other kinds of CPUs are not very good, like PowerPC, RISC. Linux memory management provides two memory management, one is the management of physical memory, the management object is the physical address, and the other is the management of virtual memory (management objects), the management object is linear address, for the process . Segment management is as indicated before, and the segment is not widely used in Linux. From the creation process of the Linux process, it is actually divided into two categories, and one is a kernel process, and the other is the user process. The two types of processes are strictly distinguished to protect the role. The linear space of the two types of processes is also strictly distinguished, and the linear address space is 4G and 3G, respectively. In Linux initialization, several paragraphs have been described, namely kernel__code, kernel__data. Segment management is a linear address space of the process. This space is consistent for most processes, that is, 4G, the kernel does not have much data structure and algorithm to handle, the only thing to understand is GDT, this table function and It roles in the process of running. Process Virtual Spatial Management (Management of Linear Address Space) All processes do not directly operate physical address, which is the biggest difference in protection mode and real mode mode, so this also provides better kernel protection. However, this approach is cost, one is on hardware, the CPU has increased complexity, and some blocks must be used in physical memory to complete the image mapping. In addition, the software must have a certain data structure to manage such a large space (4G). The management of linear address space is to get the physical memory space of the process, from linearity to physical mapping for running, the process only manages the allocation of linear space, so in the process, the Malloc class is allocated They are all linear spaces, which is to find vacancy in the directory table, fill in this linear space, prepare for management, regardless of physical memory mapping, this interrupt is a very important interrupt in the kernel, It handles the work of assigning actual physical memory, which is more unexpected in this work and contacts physical memory management.

转载请注明原文地址:https://www.9cbs.com/read-37197.html

New Post(0)