Operating system -- virtual memory, logical address, linear address, physical address

The logical address (Logical Address) refers to the offset address part related to the segment generated by the program . For example, in C language pointer programming, you can read the value of the pointer variable itself (& operation). In fact, this value is the logical address , which is relative to the address of your current process data segment, not related to the absolute physical address . Only in Intel real mode , the logical address is equal to the physical address (because there is no segmentation or paging mechanism in real mode , and Cpu does not perform automatic address translation); logic is the offset within the limit of the program execution code segment in Intel protected mode . Shift address (assuming the code segment and data segment are exactly the same). The application programmer only has to deal with logical addresses, while the segmentation and paging mechanisms are completely transparent to you and only covered by the system programmer. Although application programmers can directly manipulate memory, they can only operate in the memory segment allocated to you by the operating system.

 
Linear Address (Linear Address) is an intermediate layer between logical address to physical address translation . The program code generates the logical address, or the offset address in the segment, and the base address of the corresponding segment is added to generate a linear address. If paging is enabled, the linear address can then be translated to produce a physical address. If the paging mechanism is not enabled, then the linear address is directly the physical address . The linear address space capacity of Intel 80386 is 4G (2 to the 32nd power is 32 address bus addressing).

 
Physical address (Physical Address) refers to the address signal that addresses the physical memory on the external address bus of the CPU, and is the final result address of address translation. If paging is enabled, linear addresses are converted to physical addresses using entries in the page directory and page table. If the paging mechanism is not enabled, then the linear address becomes the physical address directly.

 
Virtual memory refers to the amount of memory that a computer presents to be much larger than it actually has. So it allows programmers to write and run programs with much more memory than the actual system has. This enables many large projects also to be implemented on systems with limited memory resources. A good analogy is: You don't need a long track to get a train from Shanghai to Beijing. You just need long enough rails (say 3km) to do this. The approach taken is to immediately lay the rear track in front of the train, and as long as your operation is fast enough and meets the requirements, the train can run as if it were a complete track. This is what virtual memory management needs to do. In the Linux 0.11 kernel, each program (process) is divided into a virtual memory space with a total capacity of 64MB. So the logical address range of the program is 0x0000000 to 0x4000000.

 
Sometimes we also refer to logical addresses as virtual addresses . Because the concept of virtual memory space is similar, the logical address is also independent of the actual physical memory capacity.

 
The "gap" between the logical address and the physical address is 0xC0000000, because the virtual address -> linear address -> physical address mapping is exactly this value. This value is specified by the operating system.

 
The method of translation from virtual addresses to physical addresses is architecture-dependent . Generally speaking, there are two methods: segmentation and paging. Taking the current x86 cpu as an example, segmented paging is supported. The Memory Management Unit is responsible for the translation from virtual addresses to physical addresses. The logical address is in the form of segment identifier + offset in the segment. The MMU can convert the logical address into a linear address by querying the segment table . If the cpu does not have paging enabled, the linear address is the physical address; if the cpu has paging enabled, the MMU also needs to query the page table to convert the linear address to a physical address:
Logical Address ---- (Segment Table) ---> Linear Address --- (Page Table) ---> Physical Address
 
Different logical addresses can be mapped to the same linear address; different linear addresses can also be mapped to the same physical address; so there is a many-to-one relationship. In addition, the same linear address may be reloaded to another physical address after a page feed occurs. So this many-to-one mapping relationship will also change over time.
 
 
http://my.oschina.net/alphajay/blog/5025

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326848234&siteId=291194637
Recommended