Linux operating system logic, linear, physical address

Source: Internet
Author: User

Logical Address(Logical Address) refers to the segment-related offset address generated by the program. For example, you can read the value (& operation) of the pointer variable in the C language pointer programming. In fact, this value is the logical address, which is relative to the address of the Data Segment of your current process, it is not related to an absolute physical address. The logical address is equal to the physical address only in Intel real mode (because the real mode does not have a segmentation or paging mechanism, the CPU does not perform automatic address translation ); the logic is the offset address of the code segment within the limit (if the code segment and data segment are identical) in Intel protection mode ). Application programmers only need to deal with logical addresses, while the segmentation and paging mechanisms are completely transparent to you and are only involved by system programmers. Although the application programmer can directly operate the memory, it can only operate on the memory segment allocated to you by the operating system.

 

Linear address(Linear address) is the intermediate layer between Logical Address and physical address transformation. The program code generates a logical address, or an offset address in the segment. A linear address is generated by adding the base address of the corresponding segment. If the paging mechanism is enabled, the linear address can be transformed to generate a physical address. If the paging mechanism is not enabled, linear addresses are physical addresses. Intel
The linear address space of 80386 is 4 GB (the power of 2 is 32 IP Address Bus addressing ).

 

Physical addressPhysical address refers to the address signal of addressing physical memory on the CPU external address bus, which is the final result address of address transformation. If the paging mechanism is enabled, linear addresses are converted to physical addresses using the items in the page Directory and page table. If the paging mechanism is not enabled, the linear address directly becomes a physical address.

 

Virtual MemoryVirtual Memory refers to the amount of memory displayed on a computer that is much larger than the actual memory. Therefore, he allows programmers to compile and run programs that are much larger than the actual system memory. This allows many large projects to be implemented on systems with limited memory resources. A very appropriate analogy is that you don't have to make a long track to drive a train from Shanghai to Beijing. You only need a long enough track (for example, 3 kilometers) to complete this task. The train tracks are immediately placed in front of the train. As long as your operations are fast enough to meet your needs, the train will be able to run on a complete track. This is the task to be completed for virtual memory management. In the linux0.11 kernel, each program (process) is divided into a virtual memory with a total capacity of 64 MB. Therefore, the logical address range of the program is 0x0000000 to 0x4000000. Sometimes we call a logical address
Virtual Address. Because it is similar to the concept of virtual memory space, 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 value of virtual address> linear address> physical address ing is exactly the same. This value is specified by the operating system. The logical address (or virtual address) of the mechanism is automatically converted from the CPU segment to the linear address. If paging management is not enabled, linear addresses are physical addresses. If paging management is enabled, the system program needs to convert parameters and linear addresses to physical addresses. Specifically, you can set the page Directory table and page table items.

 

Physical address(Physical address)

It is used for memory chip-level unit addressing, which corresponds to the address bus connected to the processor and CPU. -- This concept should be better understood among these concepts, but it is worth mentioning that although physical addresses can be directly understood as the memory itself inserted on the machine, consider the memory as a large array of serial numbers from 0 bytes to the maximum number of NULL bytes, and then call this array a physical address. But in fact, this is just a figure provided by hardware to the software, the memory addressing method is not like this. Therefore, it is more appropriate to say that it is "corresponding to the address bus", but aside from considerations of the physical memory addressing method, it directly maps the physical address to the physical memory one by one, it is also acceptable. Maybe wrong understanding is more conducive to the metaphysical image extraction.
Virtual Memory (Virtual Memory) This is the image description of the entire memory (do not insert the correct number with the machine. It is relative to the physical memory, and can be directly understood as "not straight", "fake" memory, for example, a 0x08000000 memory address, it is not the address element 0x08000000-1 in the large array on the physical address. This is because the modern operating system provides a memory management image, virtual Memory ). The process uses the address in the virtual memory, and the operating system assists the relevant hardware to "convert" it into a real physical address. This "conversion" is the key to all discussions. With this image, a program can use a much larger address space than a real physical address. (The east wall, the west wall, and the bank do the same), and even multiple processes can use the same address. It's not surprising because the converted physical addresses are not the same.
-- You can decompile the connected program and check that the connector has allocated an address to the program. For example, to call a function A, the code is call 0x0811111111 instead of call, that is to say, the address of function a has been fixed. Without such a "Conversion", there is no virtual address concept, and this is simply not feasible. The problem persists.

 

Logical Address(Logical Address)

Intel retains the segmented memory management methods of the ancient times for compatibility purposes. A logical address refers to the address in a machine language instruction that is used to specify an operand or an instruction. In the above example, the address 0x08111111 allocated by the connector for a is the logical address. -Sorry, it seems that it violates Intel's middle-stage management requirements for logical addresses, "a logical address, it is expressed
[Segment identifier: Intra-segment offset], that is, the 0x08111111 in the preceding example should be represented as [A code segment identifier: 0x08111111]. In this way, the linear address or virtual address is similar to the logical address, if the logical address is the address before the segment Management Switch of the hardware platform, the linear address corresponds to the address before the switch of the hardware page memory.

When the CPU converts an address (Logical Address) in a virtual memory space to a physical address, two steps are required: first, a logical address is given, and the CPU uses its segmented Memory Management Unit, first, convert a logical address into a thread address, and then use its webpage Memory Management Unit to convert it to the final physical address.
The two conversions are indeed very troublesome and unnecessary, because linear addresses can be directly extracted to the process. The reason for this redundancy is that intel is completely compatible.

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.