0

虚拟内存是否存在于我们计算机系统中的某个地方(即硬盘上)?

如果不是,如果数据不在主内存中,即(发生页面错误),如何进行从虚拟内存到硬盘中真实数据的映射。是否有任何表维护从虚拟内存到硬盘数据的映射..

4

5 回答 5

2
  1. 内存之所以被称为虚拟内存,是因为进程将其地址空间视为可用内存的连续块,使用底层地址总线宽度的所有宽度,比如 4GB 用于 32 位系统。所以每个进程都有一个 4GB 的地址空间,但是这个内存并没有完全由物理内存一对一地支持。即使你有 4GB 的物理内存来支持进程的 4GB 地址空间,内核会去哪里,其他进程呢?该内存必须是虚拟的。
  2. 是的,表维护进程地址空间。为简单起见,一些页面当前映射到易失性物理内存上,而另一些页面则没有。它们由 HDD 上的内存文件支持。当发生页面错误时,页面错误将检查该页面是否映射到物理内存(通常它在页面属性内部),如果没有,它将从 HDD 上的内存映射文件中获取它,并用它替换映射到物理内存的旧页面。

希望这有帮助。

于 2013-01-29T08:35:12.587 回答
1

Yes virtual memory really does exist and yes there is a table that maintains the mapping. Look for page table in wikipedia for instance. In fact most of the virtual memory article will answer your question in full.

于 2013-01-29T08:02:11.377 回答
1

Most of your questions are answered by http://en.wikipedia.org/wiki/Virtual_memory.

  1. A backing store must exist for virtual memory. This is usually a hard disk. Basically its some other device that ua usually slower than RAM but is much bigger in capacity.
  2. When a page fault occurs, the page is obtained from the backing store
  3. The page table contains information on where in the backing store the page is to found
于 2013-01-29T08:02:27.973 回答
0

Short answer, no :) Virtual Memory is virtual! Especially if you consider virtual memory as "the memory that can be addressed by a process". On 64 bit systems, the whole disk hardly could back the entire virtual memory. So "in reality", as you asked, I would say no.

Long(-ish) answer: virtual memory exists as a series of data structures in the kernel. They mostly keep trace of which page/segment is currently reserved, allocated, mapped to a file or mapped to physical memory. Also, the answer is different if what you look at is "allocated virtual memory". This always exists in one form or another (usually, pages backed by hard-disk swap space).

于 2013-01-29T08:02:03.813 回答
0

Yes, most used bytes of virtual memory exist somewhere. I say "most" because pages that map registers of some special hardware can have holes. But all memory allocated by you app exists either in RAM or on hard disk.

The wikipedia article explains all the details: http://en.wikipedia.org/wiki/Virtual_memory

于 2013-01-29T08:02:39.563 回答