Linux-0.11 Kernel Source Analysis series: About linear address, logical address, the relationship between the physical address and the difference

Source: Internet
Author: User

Tag:linux    kernel     memory management    

/* *author:davidlin *date:2014-11-22pm *email: [email protected] or [email protected]      *world:the City of SZ, in China *ver:000.000.001 *history:editor time do      * 1) Linpeng 2014-11-22 created this file! * 2) */    All of the following descriptions are based on the Linux0.11 kernel and all material and non-material base X86 Protected mode programming rules:    X86 protected mode with a physical address of 4G Space, from 0 to 0xFFFFFFFF. Of course, this is only the address bus on the size of the space can be addressable, depending on the size of the memory bar mounted on the address bus to determine. Physical Address:    Linus when writing Linux0.11 version, his computer has only 16M of memory, so the physical address described in Linux0.11 source code is from 0-16m. Linear address:    linear address is also a flat address from 0 to 0xFFFFFFFF, if no paging mechanism is turned on, the linear address equals the physical address. If the paging mechanism is turned on, the linear address to the physical address requires a two-level address translation, not a sequential mapping relationship. The linear address can be very large, but eventually run on the physical address, and the missing pages mechanism and the demand load, is to let much larger than the physical memory of the program, running in such a small physical memory, if the physical memory is large enough, perhaps these conditions will not occur. This is like a seat on the bus, assuming that the seat is memory, other standing space is hard disk, just get on the car when you are very happy, you and your girlfriend (process A, b) have seats, if at this time, there is a pregnant woman on board, the conductor elder sister (operating system) found, "Pregnant women first", so began to ask (process scheduling), but unfortunately, this system is non-preemptive, pregnant women (process s) had to wait, as an ideal and moral program ape, take the stand, they stood up (process hangs), the operating system a look, a guy put the seat (memory) released, So the pregnant woman standing in line is sitting in your original position., you switch to the bus floor (hard drive). Car to a station, pregnant women get off, so you re-seat (memory possession), in the whole operation of the public car, the seat (memory) is limited, and people do not keep up and down, so people come up first stand in the compartment, and then according to various written, unwritten rules, occupy or release memory (seat). Seats are limited, and people are relatively infinite, how to use the limited resources to serve more processes, which may be the operating system should consider. Why is the linear address not one by one mapped to the physical address? Here for example, just a personal understanding, not very rigorous: such as playing "hero Lian" and other games, running files to reach more than 10G, far more than the XP 32-bit system support 4G memory space, so we need not when the program executes all the code and data loaded into memory, It is needed when it is loaded again, which is called the demand load. First of all, login to the "hero Lian" game, the game software will apply to the operating system 1 blocks of memory, assuming that this block of memory size is 600M, Assuming that it corresponds to the physical address space of the physical address 0.6g-1.2g, for this application, it will assume that it occupies the entire 10G of memory, within the application, it considers itself from the 0 address (actually Physical address 600M) started, the game Master program will load its own code to its 0 address, assuming the main control program Occupy the relative address of the 0-300m address space, this part of the program is in memory, only when the game exits will be active release, and Other level options, are saved in the hard disk, only when necessary, will be loaded into memory (such as the relative address 300-600m address space). For example, only play the level "Tiger Elite" when memory only loaded "tiger elite" in the level of code and map data, and "Normandy Landing" level code and data are residing in the hard disk, when the player wants to be "tiger elite" level switch to "Normandy Landing" level, "Normandy Landing" The code and data for the level are covered by the code and data of the "Tiger elite" level. What if the "Normandy Landing Level" map data is larger than 600M space? or demand loading, which is why the "legend" in the game, the game characters travel will feel the map slowly on the computer screen, because it is the first time to read the map from the hard disk memory, video card display in memory data, this is a constantly updated process. Logical address:    The logical address is also called the virtual address, which refers to the address provided by the staging mechanism, consisting of the segment part and an offset part. The segment mechanism is the basis for translating virtual addresses into linear addresses. Linear address = Segment Base + offset address. For example, a data segment, assigning it a linear address address space 9M location, for the data segment inside, it does not know where the address is the beginning of the address, so it needs to get a reference system. In the compilation of the programProcess, it is that the beginning of the data segment is the location of the 0 address, so, through the segment descriptor to obtain the segment base, plus (within the paragraph) offset address, the resulting is a linear address. 

Linux-0.11 Kernel Source Analysis series: About linear address, logical address, the relationship between the physical address and the difference

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.