简体   繁体   English

进程地址空间与虚拟内存

[英]Process Address Space vs Virtual Memory

From my understanding by reading several articles I assumed Process Address Space(PAS) and Virtual Memory(VM) are same. 根据我的理解,通过阅读几篇文章,我假设进程地址空间(PAS)和虚拟内存(VM)是相同的。 Is my understanding flawed? 我的理解有缺陷吗? Can some one please shed some light on this and en light me? 有人可以对此有所了解并点亮我吗? I am confused. 我很迷惑。

I understand Process Address Space has nothing to do with Ram or Physical memory. 我理解进程地址空间与Ram或物理内存无关。

But Just confused about PAS and VM. 但只是对PAS和VM感到困惑。

First: "memory" is not equal to "address space" . 第一: “记忆”不等于“地址空间” Address space is range of posible addresses. 地址空间是可用地址的范围。 Ie it's 4 Gb for 32-bit pointers and 16 Eb for 64-bit pointers. 即32位指针为4 Gb,64位指针为16 Eb。 On the other hand, memory is... well, memory which you can actually use (at least possibly). 另一方面,内存是......好吧,你可以实际使用的内存(至少可能)。 So, I bet you're asking if "process memory" is equal to "virtual memory" or if "process address space" is equal to "virtual address space". 所以,我打赌你问的是“进程内存”是否等于“虚拟内存”,或者“进程地址空间”是否等于“虚拟地址空间”。

Second: Virtual memory is the only memory which you can use in user mode. 第二:虚拟内存是您可以在用户模式下使用的唯一内存。 You can't access physical memory. 您无法访问物理内存。 Physical memory is for kernel mode and drivers. 物理内存用于内核模式和驱动程序。 User mode applications work only with virtual memory. 用户模式应用程序仅适用于虚拟内存。 Thus, all memory is virtual in user mode. 因此,所有存储器在用户模式下都是虚拟的。 No need to append "virtual". 无需附加“虚拟”。 It's by default. 这是默认情况。

Therefore, "Process Address Space" = "[Virtual] Process Address Space" - ie the virtual address space of the single process. 因此,“进程地址空间”=“[虚拟]进程地址空间” - 即单个进程的虚拟地址空间。 The same goes for "memory": "Process Memory" = "[Virtual] Process Memory". “内存”也是如此:“进程内存”=“[虚拟]进程内存”。

Third: Now, the "Virtual Memory" term usually refer to "System Virtual Memory" (global thing), which is larger than just one process. 第三:现在,“虚拟内存”术语通常指的是“系统虚拟内存”(全局事物),它大于一个进程。 On the other hand: since addressing is specific to the process there is no such thing as "System Virtual Address Space" (global address space of all processes and kernel). 另一方面:由于寻址是特定于进程的,因此不存在“系统虚拟地址空间”(所有进程和内核的全局地址空间)。

So, the answer is: 所以,答案是:

  1. "Process Address Space" = "Virtual Address Space" = "Address Space" “进程地址空间”=“虚拟地址空间”=“地址空间”
  2. "Process Memory" <> "Virtual Memory" “进程内存”<>“虚拟内存”

Examples 例子

For example, the typical limit for process address space is 4 Gb (for 32-bit apps). 例如,进程地址空间的典型限制是4 Gb(对于32位应用程序)。 However, a typical limit of process virtual memory is 2 Gb (which can be expanded up to 3 Gb for 32-bit machines or 4 Gb for 64-bit machines). 但是,进程虚拟内存的典型限制是2 Gb(对于32位计算机可以扩展到3 Gb,对于64位计算机可以扩展到4 Gb)。

On the other hand, the virtual memory is larger than just your process. 另一方面,虚拟内存大于您的进程。 Consider the case when you allocate memory through CreateFileMapping function. 考虑通过CreateFileMapping函数分配内存的情况。 You can create, say, 64 Gb virtual memory block. 例如,您可以创建64 Gb虚拟内存块。 That's OK even though 64 Gb > 2 Gb. 即使64 Gb> 2 Gb也没问题。 Of course, you can't use all 64 Gb at the same time (because process address space is just 4 Gb), but you can do it in chunks, say, per 512 Mb. 当然,你不能同时使用所有64 Gb(因为进程地址空间只有4 Gb),但你可以用块,比如每512 Mb来完成。

Also, consider the case when you map the same virtual memory block to mupliple locations (multiple addresses). 另外,请考虑将相同的虚拟内存块映射到mupliple位置(多个地址)的情况。

In other words, one-to-one mapping between virtual memory and virtual address doesn't exist. 换句话说,不存在虚拟内存和虚拟地址之间的一对一映射。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM