Virtual memory

The virtual memory management (german virtual memory management) is a special memory management in a computer. The translation of the English term represents a Hypallage - not the management operation, but the to-manage storage is virtual. The virtual memory refers to the independent of the actually existing memory address space that is provided to a process by the operating system.

The concept originated in the 1950s and is now found in almost all modern operating systems use.

History

The concept of virtual memory management was (mostly magnetic core memory ), and secondary external storage media ( usually magnetic drum memory ), to manage them in the computers of the 1950s and the desire automatically at the same level from the separation into primary storage media on which the processor had direct access.

The concept of virtual memory was developed in 1956 by physicist Fritz -Rudolf Güntsch at the Technical University of Berlin.

In the UK, the concept of the Atlas computer project by Tom Kilburn and colleagues in 1959 demonstrated in a prototype. Computer came on the market in 1962. The concept continued in the course of the 1960s, with most operating systems from mainframes through (such as the System/360 (Model 67 ) and its successor System/370 IBM ). As for the efficient implementation of new hardware had to be developed also, there was in the 1960s still resistance to a complete implementation in operating systems. But systematic tests, conducted by the late 1960s, a team led by David Sayre at IBM fell clearly in favor of the concept of virtual memory.

The concept took place in the 1970s input even with mini computers, as in the VMS operating system by DEC for the VAX computers and Unix ( in the BSD version). For the PC, the concept continued with the advancement of processors ( with the Intel protected mode in the Intel 80286 and the Intel 80386 with Memory Management Unit ) in the operating system by, at Microsoft from Microsoft Windows 95

Motivation

The original motivation for an abstraction of the memory addresses to virtual addresses was to standardize the use and the possible combination of different memory sources. This is described by Güntsch in his dissertation of 1957 as follows:

" The programmer need for the presence of quick save to take no consideration ( he does not even need to know that they exist ). Because there is only one type of addresses, which can be programmed as if only a memory. "

The virtual memory management also enables the implementation of memory protection mechanisms for separation of

  • Programs themselves ("horizontal separation" ): programs can not access the memory of other programs (eg in case of error );
  • Programs against the operating system ( " vertical hierarchy " ): The functioning of the operating system must not be jeopardized by (incorrect ) application programs.

Another useful property of the virtual address space is the ability to provide each process an initial unfragmented, exclusive memory space available. Without virtual memory often would create memory fragmentation of the physical address space ( process- across ), which by virtual memory ( per process, and usually much larger address space than the phys memory ) can be largely avoided.

Operation

The computer system provides each process with addresses from 0 to n -1 a seemingly contiguous local memory is available, where n is the size of this memory area. In reality, this memory area of individual pages of a defined size ( " Pages", outdated and "tiles" ) within the virtual address space of the process. These virtual pages are in turn mapped to physical pages that are somewhere in physical memory or even in a paging file. When accessing a process to a memory address (a virtual address, other addresses knows the process not at all) translates the Memory Management Unit (MMU ) of the system this physical in the associated current address.

The so-called page table is the table which is used for transformation of virtual to physical page frames. Based on this table, the MMU to translate the virtual addresses into real addresses. Here is listed

  • For which virtual Page Page real which is to be used;
  • When not used virtual page is labeled such that no real page is used for this;
  • In outsourced Page is noted that / where in the page file (also: " swapfile " ) 's contents are stored.

The optimal page size ( size of a page ) is a compromise between frequency of paging and size of the table (usual sizes: 4 KiB 32 -bit virt.Adressraum, 4 MiB for 64- bit virt.Adressraum ).

Thus, a virtual address describes a location in memory of a computer system whose operating system includes a virtual memory management used for addressing. The set of all virtual addresses is also referred to as a virtual address space.

Only operating systems that use a virtual memory management can generate a virtual address space and thus represent memory pages that are not physically contiguous, the programmer or the program as a logically contiguous storage space.

Definition

Together, the virtual memory managers are now following basic principles:

The various virtual memory managers differ

Technology

Placement strategies of operating systems

Requests a program memory from the operating system, the operating system has freedoms where in virtual memory space of the process allows the program allocates the requested memory. With skillful placement strategies, continuous fragmentation of the virtual address space are reduced, which is so relevant in both a high number of memory requests and freely gave as well as the virtual address space is already very full.

Strategies for selecting appropriate addresses are:

Paging

The concept of paging in the narrower sense, only the process of mapping of virtual addresses to physical. In another ( erroneous ) meaning it is used synonymously for swapping.

Swapping

Swapping is the outsourcing of a real RAM memory area to another, secondary storage, typically. In a paging file on a hard disk by the operating system

The idea behind this is that in typical computers, the hard drive is much larger than the available electronic memory (RAM ): by the disk space can also be used to service memory requests from programs that can requests that go beyond the available RAM, then swap space be operated up to the maximum virtual memory size per process.

Disadvantage is that the paged to disk memory is much slower than RAM accessible - however, this makes the functioning of programs with high memory requirements. To mitigate the slow accessing, try operating systems using a memory monitoring to optimally distribute the RAM and swap space on the different processes. Storage areas, on the longer time was neither read nor write access can be outsourced at scarcity in the slow swap memory. Frequently used pages are kept in RAM as possible.

This actually works, by starting from a certain degree of filling of the RAM special processes ( " Page stealer " ), longer outsource non -used pages in order to gain additional physical space, so that the system can respond quickly to a request for it. This operation is asynchronous to the applications and load on the system is not much. Nevertheless, the access speed of the hard disk is relevant. Further down the main page replacement strategies are listed. Usually a combination of several methods is applied: First unread outsource, then unchanged, then longer did not change sides. As far as a more current copy of a page in the paging file exists, this page can be released for overwriting without further notice.

A page fault (English: page fault ) occurs when a program accesses a page that just is not in main memory, but was outsourced. This triggers an interrupt (English: trap ) from. The operating system then ensures that the requested memory area is loaded into the main memory so that the program can access it. The page can now be quite physically elsewhere are as originally, the Memory Management Unit considers the accordingly. The virtual address which remains unchanged. Thus, a page fault will not cause a crash, but an action which then allows the process to normal processing.

The retrieval of such sites is a process that takes much longer to access than a main memory address. Therefore, page faults slow down when they occur in large volumes, the program speed considerably. As long as it stealer succeeds in Page, make space in the main memory available, the page fault is resolved relatively quickly. The problem arises when the necessary space in main memory is not present and the trap must wait until the page has created stealer this place. The situation can escalate, so that the system mainly deals with treating page faults and reported serious loss of speed. Page stealer and the traps access both to the page file and loads at a certain point the affected hard disks completely out. This effect is referred to as side or fluttering thrashing.

Page replacement strategies of operating systems

Typical strategies to the use of RAM and slower secondary memories for all processes to be optimized:

Memory fragmentation

For systems without virtual memory management potentially enters a continuous fragmentation of the real memory space over the term. That successful operation of a newly started program is not guaranteed deterministic and depends on the fragmentation state of physical memory. Without virtual memory management, it may happen that several program runs despite constant memory request this sometimes can not be operated due to fragmentation, although getting enough total memory is free. For example, in MS- DOS, an OS without virtual memory management, an attempt was made ( etc. EMM386, QEMM ) to minimize this problem with complicated memory optimizers. These memory optimizers was tried to be as unfragmented to place device drivers and TSR programs over the iteratively determined optimal load order in the physical memory in order to make the following programs possible large blocks of memory available can. However, this approach minimizes the problem of physical memory fragmentation only and does not solve it, as opposed to virtual memory management, which provides windows applications an always identical, unfragmented memory space.

However, programs can also use virtual memory management to continuous explicit memory allocating and deallocate ( malloc (), free () ) or awkward firmly placed program libraries (DLLs) to fragment their virtual memory space itself and therefore also in time- dependent " Out of Memory" - run situations. This occurred in the 2000s at the end of the 32 -bit PC era as a practical problem (4 GB limit ); the virtual address space was no longer significantly greater than the typical physical RAM expansion, more and more programs used in accordance with a lot of memory. When using storage intensive applications such as scientific simulations ( eg, Matlab ) or complex 3D computer games (such as Gothic 3, Supreme Commander), this resulted in heaping out-of -memory problems, despite " sufficient " physical and virtual (total) memory.

Is the virtual memory space but significantly greater than the requirements of the process, a fragmentation of the virtual memory space is not a practical problem, because sufficient alternative unfragmented addresses and address range are available. With the 64- bit x86 AMD64 architecture, the virtual address space sizes were significantly increased ( also to address this problem ), and for the foreseeable future should not matter for PC programs fragmentation of the virtual memory space.

Examples

  • AMD64 architecture: Of the 64 bits of the virtual memory addresses 48 bits are in the first generation of CPUs physically for virtual memory management implemented (ie, the first 16 bits of the virtual address must be 00hex, since only 48 bits are possible - the virt address space. therefore is limited to 2 ^ 48 bytes). For this purpose a four-level page table is used. The 48 bits are divided into 9 bits each for the four side tables plus 12-bit offset.
  • IA- 32 architecture: A virtual address is 32 bits long. It is used a two- page table. The 32 bits are divided into 10 bits for the two side tables plus 12-bit offset.
  • IA- 32 architecture with PAE: A virtual address is 32 bits long. It is used a three-stage asymmetric side table. The 32 bits are divided into 2 bits for the first page and the table 9 bits for the other two side tables plus 12-bit offset.

In the IA- 32 architecture, the memory is divided into memory pages, the possible sizes and start addresses are specified by the hardware. When you access an address that is currently assigned to any physical page of memory, the operating system must have the Memory Management Unit instruct display at this point a certain free memory page. If there is no free memory page longer available, so another memory page must be set free, the content is paged by the operating system, for example, to the hard disk. This process is called paging. The size of the virtual address space can be calculated from the definition of the virtual address. For example, in an IA-32 architecture, a virtual address is 32 bits wide, twice each with 10 bits for a two- bit page table, and 12 for the offset. Thus, 210 x 210 x 212 bytes can be addressed. These are 232 bytes, ie 4 GiB.

514699
de