Differences between logical addresses, linear addresses, and physical addresses

Source: Internet
Author: User

Differences between logical addresses, linear addresses, and physical addresses in segment-page memory management

 

Linear addresses are the intermediate layer between logical addresses and physical address transformations. They are addresses in the memory space (called linear address space) that the processor can address. The program code will generate 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, linear addresses can be transformed to generate a physical address. If the paging mechanism is not enabled, linear addresses are physical addresses. However, after the paging function is enabled, a linear address may not have a corresponding physical address, because the corresponding memory may be switched to the hard disk. A 32-bit linear address can be used to locate a 4 GB storage unit.

The so-called physical address refers to the real address of the system memory. For 32-bit operating systems, the range is 0x00000000 ~ 0 xffffffff, total 4 GB. This type of address is "interesting" only when the CPU is working in paging mode ". Essentially, a physical address is the voltage that can be measured on the CPU pin. The operating system maps a linear address to a physical address by setting up a page table. Some attributes of the page table layout used by Windows 2 k/XP are very useful for debugging software developers.

The paging mechanism divides linear address space and physical address space into blocks of the same size. Such a block is called a page. By establishing a ing between pages in a linear address space and pages in a physical address space, the paging mechanism can convert linear addresses to physical addresses. The ing between a linear address space page and a physical address space page can be determined as needed. Any page of the linear address space can be mapped to any page of the physical address space.

 

 

 

A logical address is a segment-related offset generated by a 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 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. The linear address space of Intel x86 is 4 GB (the power of 2 is the power of 32 address bus addressing ).

Physical address refers to the address signal of addressing physical memory on the CPU external address bus. It 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 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 logical addresses as virtual addresses. 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.

 

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.