Virtual memory management
2006-12-12 18:50
706 查看
Virtual memory management
Virtual Memory Manager (VMM) Overview
The Virtual Memory Manager (VMM) provides the virtual memory facilities that are used by the other parts of the system to implement the following:
· Virtual address space of processes
· Sharing of executables
· Shared memory segments
· Mapped files
The VMM implements virtual memory, allowing the creation of segments larger than the physical memory available in the system. The segments are divided into fixed-size units called pages. Each page in a segment can be in physical memory or stored on disk until it is needed. When a process accesses a page that is not present in physical memory, the VMM reads the page into memory; this is called a PageIn. When physical memory is not available, the VMM writes pages to disk; this is called a PageOut or PageSteal.
The following are some of the segment types:
Virtual address space
内存映射文件的学习
Jeffrey Richter对Memory-Mapping File已经讲述的很详细了,现在我们可以归纳以下:
一、功能
1. 简化对数据文件的操作。(利用内存映射文件,Windows将会负责文件数据在RAM的缓存及其和磁盘的数据交换,消除了我们很多麻烦)
2. 进程间共享数据和通讯。(主要是创建一个Memory-Mapping File对象,这个Memory-Mapping File对象使用INVALID_HANDLE_VALUE来模拟创建一个由Page File而不是硬盘上数据文件所支持的对象,然后在多个进程间共享这个对象(3种方法),然后利用更新同样的RAM数据来实现同步更新,及其通讯)
3. 理解操作系统的Loader机理。(OS Loader也是调用CreateFile,CreateFileMapping及其MapViewOfFileEx 来加载一个.exe文件)
二、使用
CreateFile: Calling CreateFile tells the operating system the location of the file mapping's physical storage.
CreateFileMapping: Create a file-mapping kernel object that tells the system (1) the size of the file and (2) how you intend to access the file.(When you create a file-mapping object, the system does not reserve a region of address space and map the file's storage to the region)。如果此函数所指定的大小比硬盘上的文件大的话,文件将会扩展为此函数所指定的大小。
MapViewOfFileEx: reserve a region of address space for the file's data and commit the file's data as the physical storage that is mapped to the region。(note: if we do not touch much of the view, windows virtual memory manager will not page the physical storage into RAM)
三、实现细节
CreateFile函数将一个hFile对象与磁盘上的一个文件对应起来
CreateFileMapping将会将此hFile对应的磁盘文件映射到到一组RAM页面,不过并不为其保留进程的虚拟地址空间,也不为其提交内存?(它还没有被分配虚拟内存地址,所以根本不能被访问)
MapViewOfFile将前面创建的FileMapping对象映射进进程的虚拟地址空间,并且提交内存。
由上面可以看到,相同的FileMapping对象代表着相同的RAM页面,所以对于同一个FileMapping对象的不同View修改会造成同一块内存页面被多次修改。
Tip:
1. CreateFileMapping在已经有一个FileMapping存在的情况下返回值并不是NULL,而返回现在已经存在的FileMapping的句柄GetLastError returns ERROR_ALREADY_EXISTS,所以一定要看文档。
posted @ 2005-02-01 11:07 比尔盖房 阅读(203) | 评论 (0) | 编辑 收藏
2005年1月31日 #
Windows内存管理
哎, Windows核心编程被翻译的太烂了。
我需要在这里将内存管理这一章的一些内容给解释清楚:
Partition:Each process's virtual address space is split into partitions.
Region(区域):是通过VirtualAllocEx函数进行保留的一段虚拟地址空间(The act of allocating a region is called reserving.)
Virtual Memory==Physical Storage==Physical Memory(That is RAM)+ Page File(Or a Memory Mapping file on disk)
Reserve(保留):The act of allocating a region(in Vritual Address space) is called reserving.
Commit(提交):allocate physical storage(not RAM) and then map this storage to the reserved region.
Block(块): A block is a set of contiguous pages that all have the same protection attributes and that are all backed by the same type of physical storage
Process Address Space:A 4G virtual address space
Reserve:开始地址向小的方向调整为分配粒度64K的倍数 保留大小为Page Size的倍数
Commit:开始地址向小的方向调整为Page Size的倍数 保留大小为Page Size的倍数
Memory-mapped file:When a program's file image (that is, an .exe or a DLL file) on the hard disk is used as the physical storage for a region of address space, it is called a memory-mapped file。
Virtual Memory Manager (VMM) Overview
The Virtual Memory Manager (VMM) provides the virtual memory facilities that are used by the other parts of the system to implement the following:
· Virtual address space of processes
· Sharing of executables
· Shared memory segments
· Mapped files
The VMM implements virtual memory, allowing the creation of segments larger than the physical memory available in the system. The segments are divided into fixed-size units called pages. Each page in a segment can be in physical memory or stored on disk until it is needed. When a process accesses a page that is not present in physical memory, the VMM reads the page into memory; this is called a PageIn. When physical memory is not available, the VMM writes pages to disk; this is called a PageOut or PageSteal.
The following are some of the segment types:
Working storage | Segments are used to implement the data areas of processes and shared memory segments. The pages for working storage segments are stored in the paging spaces configured in the system. | ||
Persistent storage | Segments are used to manipulate files and directories. When a persistent storage segment is accessed, the pages are read and written from its file system. | ||
Client storage | Segments are used to implement some virtual file systems like Network File System (NFS) and the CD-ROM file system. The storage for client segment pages can be in a local or remote computer. | ||
| |||
内存映射文件的学习
Jeffrey Richter对Memory-Mapping File已经讲述的很详细了,现在我们可以归纳以下:
一、功能
1. 简化对数据文件的操作。(利用内存映射文件,Windows将会负责文件数据在RAM的缓存及其和磁盘的数据交换,消除了我们很多麻烦)
2. 进程间共享数据和通讯。(主要是创建一个Memory-Mapping File对象,这个Memory-Mapping File对象使用INVALID_HANDLE_VALUE来模拟创建一个由Page File而不是硬盘上数据文件所支持的对象,然后在多个进程间共享这个对象(3种方法),然后利用更新同样的RAM数据来实现同步更新,及其通讯)
3. 理解操作系统的Loader机理。(OS Loader也是调用CreateFile,CreateFileMapping及其MapViewOfFileEx 来加载一个.exe文件)
二、使用
CreateFile: Calling CreateFile tells the operating system the location of the file mapping's physical storage.
CreateFileMapping: Create a file-mapping kernel object that tells the system (1) the size of the file and (2) how you intend to access the file.(When you create a file-mapping object, the system does not reserve a region of address space and map the file's storage to the region)。如果此函数所指定的大小比硬盘上的文件大的话,文件将会扩展为此函数所指定的大小。
MapViewOfFileEx: reserve a region of address space for the file's data and commit the file's data as the physical storage that is mapped to the region。(note: if we do not touch much of the view, windows virtual memory manager will not page the physical storage into RAM)
三、实现细节
CreateFile函数将一个hFile对象与磁盘上的一个文件对应起来
CreateFileMapping将会将此hFile对应的磁盘文件映射到到一组RAM页面,不过并不为其保留进程的虚拟地址空间,也不为其提交内存?(它还没有被分配虚拟内存地址,所以根本不能被访问)
MapViewOfFile将前面创建的FileMapping对象映射进进程的虚拟地址空间,并且提交内存。
由上面可以看到,相同的FileMapping对象代表着相同的RAM页面,所以对于同一个FileMapping对象的不同View修改会造成同一块内存页面被多次修改。
Tip:
1. CreateFileMapping在已经有一个FileMapping存在的情况下返回值并不是NULL,而返回现在已经存在的FileMapping的句柄GetLastError returns ERROR_ALREADY_EXISTS,所以一定要看文档。
posted @ 2005-02-01 11:07 比尔盖房 阅读(203) | 评论 (0) | 编辑 收藏
2005年1月31日 #
Windows内存管理
哎, Windows核心编程被翻译的太烂了。
我需要在这里将内存管理这一章的一些内容给解释清楚:
Partition:Each process's virtual address space is split into partitions.
Region(区域):是通过VirtualAllocEx函数进行保留的一段虚拟地址空间(The act of allocating a region is called reserving.)
Virtual Memory==Physical Storage==Physical Memory(That is RAM)+ Page File(Or a Memory Mapping file on disk)
Reserve(保留):The act of allocating a region(in Vritual Address space) is called reserving.
Commit(提交):allocate physical storage(not RAM) and then map this storage to the reserved region.
Block(块): A block is a set of contiguous pages that all have the same protection attributes and that are all backed by the same type of physical storage
Process Address Space:A 4G virtual address space
Reserve:开始地址向小的方向调整为分配粒度64K的倍数 保留大小为Page Size的倍数
Commit:开始地址向小的方向调整为Page Size的倍数 保留大小为Page Size的倍数
Memory-mapped file:When a program's file image (that is, an .exe or a DLL file) on the hard disk is used as the physical storage for a region of address space, it is called a memory-mapped file。
相关文章推荐
- Talking from Virtual Memory Management: from virtual address to physical address ...
- Virtual Memory Management in VAX/VMS Operating System
- memory management in the java HotSpot Virtual Machine(中文翻译)
- Linux Memory Management – Virtual Memory and Demand Paging
- understanding the linux virtual memory management 图序
- Memory Tips: Physical and Virtual Memory Management, Global Sections, System Parameters
- Spark 1.6 内存管理模型( Unified Memory Management)分析
- Not enough physical memory is available to power on this virtual machine
- Memory Management Policy
- Xen Memory Management
- elasticsearch max virtual memory areas vm.max_map_count [65530] is too low, increase to at le
- LA2238 Fixed Partition Memory Management
- Client-Side Javascript Memory Management
- Virtual Memory$$memory-mapped-files
- /LGC图形渲染/Memory management for graphics processors
- Simple summary of virtual memory
- ARM Virtual - Physical memory translation
- Linux Kernel Memory Management (2)
- Windows CE Virtual Memory Layout for Debugging
- Memory Management in R: A Few Tips and Tricks