简体   繁体   English

虚拟地址空间和虚拟内存有什么区别?

[英]What is the difference between virtual address space and virtual memory?

When a process is created by the user a virtual space address is created which is is the size 4g for a 32 bit os (0 to 2^32-1)?当用户创建一个进程时,会创建一个虚拟空间地址,它是 32 位操作系统(0 到 2^32-1)的 4g 大小? The process thinks its has the whole memory to use but the virtual addresses are converted to physical addresses and stored in the page table of the process.进程认为它有整个内存可以使用,但虚拟地址被转换为物理地址并存储在进程的页表中。 I am confused that what virtual memory is then?我很困惑什么是虚拟内存? Is it same as virtual address space?它与虚拟地址空间相同吗?

What is the difference between virtual address space and virtual memory?虚拟地址空间和虚拟内存有什么区别?

The virtual address space is literally space (in the same way that a backyard shed is storage space).虚拟地址空间实际上是空间(就像后院棚屋是存储空间一样)。

Virtual memory is something you can put in the virtual space (in the same way that gardening tools are something that you could put in a backyard shed).虚拟内存是您可以放在虚拟空间中的东西(就像园艺工具可以放在后院棚子里的东西一样)。

You could also leave part of the virtual address space empty/unused;您也可以将部分虚拟地址空间留空/未使用; or put something that does not behave like memory (eg a memory mapped device) in the virtual address space (in the same way that you could leave part of a backyard shed empty, or put things that aren't garden tools in the shed).或者在虚拟地址空间中放置一些不像内存的东西(例如内存映射设备)(就像你可以把后院棚子的一部分留空,或者把不是园艺工具的东西放在棚子里) .

For a more complete example;一个更完整的例子; let's say you have a 32-bit system and virtual address spaces are 4 GiB or 4096 MiB.假设您有一个 32 位系统,虚拟地址空间为 4 GiB 或 4096 MiB。 This 4096 MiB of space may be split 3072 MiB of "user-space" that the process could use, and 1024 MiB of "kernel space" that is reserved for the kernel itself.这 4096 MiB 的空间可能被拆分为 3072 MiB 的进程可以使用的“用户空间”,以及为内核本身保留的 1024 MiB 的“内核空间”。 In this case it might end up like:在这种情况下,它可能最终像:

  • 1024 MiB of space used by the process for virtual memory进程使用的 1024 MiB 空间用于虚拟内存

  • 2048 MiB of space that isn't used by the process (and isn't virtual memory)进程未使用的 2048 MiB 空间(不是虚拟内存)

  • 128 MiB of space used by the kernel for virtual memory内核用于虚拟内存的 128 MiB 空间

  • 32 MiB of space used by the kernel for memory mapped devices (that isn't virtual memory)内核用于内存映射设备(不是虚拟内存)的 32 MiB 空间

  • 864 MiB of space that is not used by the kernel (and isn't virtual memory)内核未使用的 864 MiB 空间(并且不是虚拟内存)

In that case;在这种情况下; you'd have a total of "1024 + 128 = 1152 MiB" of virtual memory (and "2048 + 32 + 864 = 2944 MiB" of space that isn't virtual memory).你总共有“1024 + 128 = 1152 MiB”的虚拟内存(以及“2048 + 32 + 864 = 2944 MiB”的非虚拟内存空间)。

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

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