Virtual Memory (1)

Source: Internet
Author: User
Virtual Memory (1) translated from the Computer Science Department of George Mason University online tutorial Virtual Memory Module

Author: Jill bobbin and Priscilla McAndrews Liu Jianwen translated (http://blog.csdn.net/keminlau

)

Key: Virtual Memory

Introduction

Virtual Memory was receivted in 1959 to hide the Memory Hierarchy and significantly simplify programming. now so common that no one pays much attention to it, virtual memory is one of the great engineering triumphs (triumph, Joy, victory) of the computer age.

Virtual Memory was invented in 1959 to hide the layered structure of computer storage systems, greatly simplifying subsequent programming tasks. Nowadays, virtual memory is so common that we seldom pay attention to its existence and have a deep understanding of its principles. Virtual Memory is a great engineering invention in the computer age.

Subway Map

Why do we need virtual memory?

Storage allocation has always been an important consideration in computer programming due to the high cost of main memory and the relative abundance and lower cost of secondary storage. program code and data required for execution of a process must reside in main memory to be executed, but main memory may not be large enough to accomodate the needs of an entire process. early computer programmers divided programs into sections that were transferred into main memory for a period of processing time. as the program proceeded, new sections moved into main memory and replaced sections that were not needed at that time. in this early era of computing, the programmer was responsible for devising this overlay system.

Because primary storage is always relatively rare and expensive, while secondary storage is relatively adequate (abundance) and cheap, how to make better use of limited primary storage has always been a matter of great importance. The program code and data must be put into the primary storage to run, but the actual primary storage capacity may not be enough to accommodate the storage demand (Kemin: most of the storage space required for running the current program changes dynamically, which is one of the major reasons why the storage management system is difficult to design ). The early storage management system was designed to solve the storage availability problem, instead of the storage efficiency problem. The programmer must be responsible for developing a pre-memory management system-overlay system to solve the problem of memory availability. At that time, the operating system had not yet appeared, and the programmer implemented overlay system through explicit encoding. The programmer divides the program into different segments, and each segment is loaded into the main memory for a period of time. As the program runs, the new program segments will be loaded and replaced with those that are no longer needed.

As higher level programming ages became popular for writing more complex programs and the programmer became less familiar with the machine, the efficiency of complex programs suffered from poor overlay systems. the problem of storage allocation became more complex.

By the middle of 1950s, after the introduction of advanced languages, programmers were advised to focus on solving problems without having to focus too much on memory management details. However, as the complexity of the Program increases, the difficulty of memory management increases. In the late 1950s S, the overlay system without design had severely restricted the program performance and became an urgent problem. However, programmers under the High-level language protection (shielded) have been hard to persuade to return to the low-level language for memory management optimization. This situation has been delayed until the emergence of large memory capacity.

Two Theories for solving the problem of ineffiecient memory management emerged -- static and dynamic allocation. static allocation assumes that the availability of memory resources and the memory reference string of a program can be predicted. dynamic Allocation relies on memory usage increasing and decreasing with actual program needs, not on predicting memory needs.

Two theories are proposed to solve the problem of inefficient memory management: static allocation and dynamic allocation. Static allocation assumes that the availability of memory resources and the memory access behavior of the Program (this behavior is abstracted as a memory reference string concept) can be predicted. Dynamic Allocation is performed based on the actual needs of the program, and the memory needs not be predicted.

 

What is storage allocation? What is the nature of the storage allocation problem?

These two approaches differ on their assumptions about the most fundamental aspect of the storage allocation problem, prediction, both (1) of the availability of memory resources, and (2) of certain properties of a program's "reference string," I. e. its sequence of references to information.

To solve the storage allocation problem

First, prediction of memory resource availability (prediction );

Second, the prediction of certain properties of the reference string of the program (such as the reference sequence of information.

Kemin: modern application developers may be hard to understand what is predictions about storage allocation, because advanced languages give them all logic, and all allocation details are handed over to the compiler. Another reason is that it is hard to imagine the possibility of this prediction, because it is possible to allocate all the storage needs to it before the program runs? See Peter J. Denning

Virtual Memory published in 1970

"

 

 

 

Reference string


The reference string is the series of virtual page references generated during the execution of a program. the reference string is represented by W = r (1) R (2) R (3 )... r (t), where r (t) is the virtual page in memory and T is the virtual processing time for a program [D3]. the reference string is used in

  • * Observing program behavior

  • * Determining lifetime curve of a program for various replacement policies.

Reference string refers to the reference sequence of virtual memory pages generated during the program running. Expressed by formula: W = r (1) R (2) R (3 )... r (t), where r (t) represents the virtual page, t represents the processing time. Reference string can be used:

  • * Analyze and observe program behavior;

  • * Depicts the life time curve of a program when different replacement policies are used ).

P

Rogram objectives and machine advancements in the '60s made the predictions required for static allocation difficult, if not impossible. therefore, the dynamic allocation solution was generally accepted, but opinions about implementation were still divided. one group believed the programmer shocould continue to be responsible for storage allocation, which wocould be accomplished by system callto allocate or deallocate memory. the second group supported Automatic Storage Allocation specified med by the operating system, because of increasing complexity of storage allocation and emerging importance of multiprogramming. in 1961, two groups proposed a one-level memory store. one proposal (proposal, proposal, Plan) called for a very large main memory to alleviate (mitigating, easing) any need for storage allocation. this solution was not possible due to very high cost. the second proposal is known as virtual memory. [D1]

After 1960s, with the transfer of computer applications (such as switching from computing to data processing) and the development of computer technology, static allocation cannot be called impossible, but it also becomes very difficult. The idea of dynamic allocation is accepted. However, in the camp where supporters are dynamically distributed, there are still differences on the specific implementation methods. One opinion is that programmers must continue to be responsible for storage allocation and use the system calls provided by the operating system, because programmers are familiar with program behaviors (such as algorithms, we should try our best to improve the program running efficiency through manual storage allocation. Another suggestion is that the storage allocation is becoming more and more complex. In addition, the multi-channel program is the mainstream, and the cost of manual allocation is too high, the operating system must provide a fully automatic storage allocation mechanism. The primary cause of storage allocation is that the programmable primary storage is too small. In 1961, the two groups proposed some solutions (proposal), one of which introduced large-capacity primary storage, however, it was not implemented because the cost was too high. Another proposal was the famous virtual memory.

Definition

Virtual Memory is a technique that allows processes that may not be entirely in the memory to execute by means of automatic storage allocation upon request. the term virtual memory refers to the specified action of separating logical memory -- memory as seen by the process -- from physical memory -- memory as seen by the processor. because of this separation, the programmer needs to be aware of only the logical memory space while the operating system maintains two or more levels of physical memory space.

Virtual Memory is a technology that allows a process to run without being loaded into the primary memory by automatically allocating storage space as needed. The term virtual memory means to separate physical memory (processor visible memory) from logical memory (process visible memory ). With this separation, programmers only need to care about the logical storage space when programming, and the operating system is responsible for the use of the actual physical storage space.

The Virtual Memory action is implemented by using secondary storage to augment the processor's main memory. data is transferred from secondary to main storage as and when necessary and the data replaced is written back to the secondary storage according to a predetermined replacement algorithm. if the data swapped is designated a fixed size, this swapping is called paging; if variable sizes are permitted and the data is split along logical lines such as subroutines or matrices, it is called segmentation. some operating systems combine segmentation and paging. [D1] [s2]

The virtual memory technology uses secondary storage to expand the main memory of the processor. When and where data is imported into and out of the primary storageReplacement Algorithm
The data size is fixed.Paginated virtual storage
, The data size is not fixed (the data size may be divided according to the logical line, such as the subroutine size or the size of a matrix)Segmented virtual storage
. Some operating systems use two methods to implement virtual memory.

The distriillustrates that a program generated address (1) or "Logical Address" consisting of a logical page number plus the location within that page (X) must be interpreted or "mapped" onto an actual (physical) Main Memory Address by the operating system using an address translation function or mapper (2 ). if the page is present in the main memory, the Mapper substitutes the physical page frame number for the logical number (3 ). if the Mapper detects that the page requested is not present in main memory, a fault occurs and the page must be read into a frame in main memory from secondary storage (4, 5 ). [D2] pp. 161-165

Demonstrate the basic principles of virtual memory:

  1. A logical address reference generated by the program. The logical address consists of the logical page number plus the location X on the page;
  2. The address er of the operating system is responsible for converting logical addresses,
    1. If the required page is in the primary storage, mapper replaces the logical page number with the physical page number (called the page frame;
    2. If the required page does not exist in the primary storage, that is, the page missing event is generated, mapper must first process the page missing event and read the required page from the secondary storage into the primary storage as a page frame.

What do you think are the main considerations in implementing this virtual memory system?

From the above basic principle, what do you think is the main problem or task for implementing a virtual memory system?

 

Related Article

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.