Basic MMU concepts

Source: Internet
Author: User

Http://baike.baidu.com/view/969924.htm,http://mopf. I .sohu.com/blog/view/159367153.htm

I. MMU's history many years ago, when people were still using DOS or older operating systems, the computer's memory was still very small and generally calculated in K units, correspondingly,ProgramThe size is not big, so although the memory capacity is small, it can still accommodate the current program. However, with the rise of the graphic interface and the increasing user demand, the scale of applications also expands, and finally a difficult problem arises in front of programmers, that is, the application is so large that the memory cannot accommodate the program. The common solution is to split the program into many fragments called overlay. Overwrite Block 0 is run first. At the end, it calls another overwrite block. Although the swap of the covered block is completed by the OS, it is time-consuming and labor-consuming and tedious to split the program first by the programmer. People must find a better way to fundamentally solve this problem. Soon, people found a way, which isVirtual Storage (virtual
Memory ).Virtual MemoryBasic IdeasYesThe total size of programs, data, and stacks can exceed the size of physical storage. The operating system keeps the currently used parts in the memory, and saves other unused parts on the disk.. For example, for a 16 MB program and a machine with a memory of only 4 MB, the operating system can choose which 4 MB of content is stored in the memory at each time, swap program segments between memory and disk as needed, so that the 16 M program can be run on a machine with only 4 M memory. This 16 M program does not need to be separated by programmers before running.

Ii. MMU related concepts

--Address rangeIng virtual addresses to physical addresses andPaging Mechanism

At any time, there is a set of addresses that a program can generate on the computer.Address range. The size of this range is determined by the number of cpus. For example, a 32-bit CPU has a range of 0 ~ 0 xffffffff (4G ),64-bitCPU, its address range is 0 ~ 0 xffffffffffffff (64 TB). This range is the address range that our program can generate.The address range is called virtual address space.An address in this space is called a virtual address. The physical address space and physical address correspond to the virtual address space and virtual address. In most cases, the physical address space of our system is only a subset of the virtual address space. Here is a simple example to illustrate the two. For a 32bit with MB memory
For x86 hosts, its virtual address space ranges from 0 ~ 0 xffffffff (4G), and the physical address range is 0x000000000 ~ 0x0fffffff (256 m ).

On a machine that does not use virtual memory, the virtual address is directly sent to the memory bus, so that the physical memory with the same address is read and written.Virtual Memory UsedIn this case, the virtual address is not directly sent to the memory address bus, but toMaps virtual addresses to physical addresses in the memory management unit MMU..

Most systems that use virtual memory usePaging(Paging) Mechanism.Virtual Address SpaceDividedPage(Page), and the correspondingPhysical address spaceAlso divided, unit:Pagination (Frame). The page and page must be in the same size. In this example, we have a machine that can generate a 32-bit address. Its virtual address range is from 0 ~ 0 xffffffff (4G), and this machine has only M physical address, so it can run4G programBut the program cannot be transferred to the memory for one-time operation. This machine must have an external memory (such as a disk or flash) that can store 4G programs to ensure that program fragments can be called as needed. In this example,The page size is 4 kb. The page size is the same as the page size.-- This must be ensured becauseBetween memory and peripheral memoryTransmission is always in the unit of page. Corresponding to 4G virtual addresses and M physical storage, they contain1 MB pages and 64 K pages.

Iii. MMU functions 1. ing virtual addresses to physical addresses

A modern multi-user multi-process operating system requires MMU to achieve the goal that each user process has its own address space. Using MMU, the operating system divides an address area. In this address area, the content of each process is not necessarily the same. For example, in Microsoft Windows, the address range of 4-2 GB is divided into user address space, and process a maps the executable file in address 0x400000 (4 m, process B maps the executable file in the address 0x400000 (4 m). IfThe read address of process a is 0x400000. When process B reads the address 0x400000, the executable file of process a is mapped to ram, it reads the contents of B's executable file mapped to ram..

This is the role of MMU in address translation.

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.