2015.4.8 Virtual Memory

Source: Internet
Author: User

The program is divided into virtual pages, memory is divided into page frames, and virtual pages can be mapped to any one page frame in a fully connected way.

SRAM is equivalent to DRAM cache, and DRAM is equivalent to the cache of hard disk, but we look at the cost, memory misses compared to SRAM misses the cost is much greater, so we have to use all means to reduce the miss of memory, so we have a fully connected method to map, and use write-back instead of straight write.

So in the scheduling process, which page we call from the hard disk, the policy of replacing which sacrifice page is implemented by the operating system, the MMU, and the page table. Page table is equivalent to a mapping, is the role of virtual conversion, and the specific implementation is implemented by the operating system.

The page table is a single item (page table Entry,pte), which contains a single mapping. This is a map that can be changed. We can think of this: this page table represents a map that defines the mapping of the field to the domain, which is full-shot. Whenever I take an element in a defined field, if there is a range, then I will take the value, and the counter plus one, if there is no mapping, then the proof I need is not in the current mapping, then I will delete the lowest usage of the map to replace the one I currently need.

This table so far we have to see what we need, define the domain: The number of the virtual page; Tags: whether the elements in the current definition field are used, such as used[i] the meaning of this array, the range that represents the physical address to which my current virtual address is mapped.

When I need data, I naturally first find the page table, see if I need the item is in the page table, if, hit, I directly fetch the data is good; if not, this time, into the exception handler, call a page break, and then find a sacrifice pages, data if there is a change will be written back, Then redeployment the data I need into memory and re-executes the current instruction.

Because of the local principle, this strategy is actually very efficient, although the lack of cost is very large, but it is not easily missing. Of course, for the missing, if the resident set (working set, the program frequently active interface collection) is larger than the physical memory size, the program will be bumpy, often have interface swap out. For example: movies.

* When we assign a new page and call malloc, we are actually creating a new item in the page table, which is equivalent to adding an element to the definition field.

* On-demand interface scheduling (when I need the interface into memory, other methods such as prediction interface) and the combination of separate virtual address space can greatly optimize our system.

To control what the page accesses, we then add three characters to each PTE to control the Sup,read,write, meaning whether the superuser is accessible, readable, writable

2015.4.8 Virtual Memory

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.