Virtual address space
Template:Short description Template:Redirect2 Template:One source
In computing, a virtual address space (VAS) is an area of contiguous virtual memory locations, called virtual addresses, which an operating system makes available to a process for executing instructions and storing data, and which it maps to the address space of physical addresses in a computer's hardware memory.[1] The range of virtual addresses usually starts at a low address and can extend to the highest address allowed by the computer's instruction set architecture and supported by the operating system's pointer size implementation, which can be 4 bytes for 32-bit or 8 bytes for 64-bit OS versions. This provides several benefits including security through process isolation, assuming each process is given a separate address space.
Example
- In the following description, the terminology used will be particular to the Windows NT operating system, but the concepts are applicable to other virtual memory operating systems.
When a new application on a 32-bit OS is executed, the process has a Template:Nowrap VAS: each one of the memory addresses (from 0 to 232 − 1) in that space can have a single byte as a value. Initially, none of them have values (<syntaxhighlight lang="text" class="" style="" inline="1">-</syntaxhighlight> represents no value). Using or setting values in such a VAS would cause a memory exception.
Then the application's executable file is mapped into the VAS. Addresses in the process VAS are mapped to bytes in the EXE file. The OS manages the mapping:
The symbol <syntaxhighlight lang="text" class="" style="" inline="1">v</syntaxhighlight> represents values from bytes in the mapped file. Required DLL files are then mapped (this includes custom libraries in addition to system libraries such as <syntaxhighlight lang="text" class="" style="" inline="1">kernel32.dll</syntaxhighlight> and <syntaxhighlight lang="text" class="" style="" inline="1">user32.dll</syntaxhighlight>):
The process then starts executing bytes in the EXE file. However, the only way the process can use or set <syntaxhighlight lang="text" class="" style="" inline="1">-</syntaxhighlight> values in its VAS is to ask the OS to map them to bytes from a file. A common way to use VAS memory in this way is to map it to the page file. The page file is a single file, but multiple distinct sets of contiguous bytes can be mapped into a VAS:
And different parts of the page file can map into the VAS of different processes:
On Microsoft Windows 32-bit, by default, only Template:Nowrap are made available to processes for their own use.[2] The other Template:Nowrap are used by the operating system. On later 32-bit editions of Microsoft Windows, it is possible to extend the user-mode virtual address space to Template:Nowrap while only Template:Nowrap is left for kernel-mode virtual address space by marking the programs as <syntaxhighlight lang="text" class="" style="" inline="1">IMAGE_FILE_LARGE_ADDRESS_AWARE</syntaxhighlight> and enabling the <syntaxhighlight lang="text" class="" style="" inline="1">/3GB</syntaxhighlight> switch in the <syntaxhighlight lang="text" class="" style="" inline="1">boot.ini</syntaxhighlight> file.[3][4]
On Microsoft Windows 64-bit, in a process running an executable that was linked with <syntaxhighlight lang="text" class="" style="" inline="1">/LARGEADDRESSAWARE:NO</syntaxhighlight>, the operating system artificially limits the user mode portion of the process's virtual address space to 2 GiB. This applies to both 32- and 64-bit executables.[5][6] Processes running executables that were linked with the <syntaxhighlight lang="text" class="" style="" inline="1">/LARGEADDRESSAWARE:YES</syntaxhighlight> option, which is the default for 64-bit Visual Studio 2010 and later,[7] have access to more than Template:Nowrap of virtual address space: up to Template:Nowrap for 32-bit executables, up to Template:Nowrap for 64-bit executables in Windows through Windows 8, and up to Template:Nowrap for 64-bit executables in Windows 8.1 and later.[4][8]
Allocating memory via C's malloc establishes the page file as the backing store for any new virtual address space. However, a process can also explicitly map file bytes.
Linux
For x86 32-bit CPUs, Linux allows splitting the user and kernel address ranges in different ways: 3G/1G user/kernel (default), 1G/3G user/kernel or 2G/2G user/kernel.[9]
See also
References
Further reading
Template:Data types de:Virtueller Adressraum
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ 4.0 4.1 {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}
- ↑ {{#invoke:citation/CS1|citation |CitationClass=web }}