虚拟内存和物理内存之间有什么区别? [英] What are the differences between virtual memory and physical memory?

查看:564
本文介绍了虚拟内存和物理内存之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常对操作系统中的虚拟化概念感到困惑.考虑到RAM是物理内存,为什么我们需要虚拟内存来执行进程?

I am often confused with the concept of virtualization in operating systems. Considering RAM as the physical memory, why do we need the virtual memory for executing a process?

将来自外部硬盘驱动器的进程(程序)带到主内存(物理内存)以执行该虚拟内存的位置.

Where does this virtual memory stand when the process (program) from the external hard drive is brought to the main memory (physical memory) for the execution.

谁负责虚拟内存,虚拟内存的大小是多少?

Who takes care of the virtual memory and what is the size of the virtual memory?

假设RAM的大小为4GB(即2 ^ 32-1地址空间),那么虚拟内存的大小是多少?

Suppose if the size of the RAM is 4GB (i.e. 2^32-1 address spaces) what is the size of the virtual memory?

推荐答案

虚拟内存尤其是一种抽象,它使程序员有在其系统上拥有无限内存的错觉.

Virtual memory is, among other things, an abstraction to give the programmer the illusion of having infinite memory available on their system.

使虚拟内存映射与实际的物理地址相对应. 操作系统创建并处理这些映射-利用页表以及其他数据结构来维护映射.虚拟内存映射始终在页表或某些类似的数据结构中找到(对于其他虚拟内存实现,我们可能不应该将其称为页表").页表也位于物理内存中-通常位于用户程序无法覆盖的内核保留空间中.

Virtual memory mappings are made to correspond to actual physical addresses. The operating system creates and deals with these mappings - utilizing the page table, among other data structures to maintain the mappings. Virtual memory mappings are always found in the page table or some similar data structure (in case of other implementations of virtual memory, we maybe shouldn't call it the "page table"). The page table is in physical memory as well - often in kernel-reserved spaces that user programs cannot write over.

虚拟内存通常大于物理内存-如果虚拟内存和物理内存大小相同,则没有太多理由进行虚拟内存映射.

Virtual memory is typically larger than physical memory - there wouldn't be much reason for virtual memory mappings if virtual memory and physical memory were the same size.

通常,程序的所需部分仅驻留在内存中-这是一个称为分页"的主题.虚拟内存和分页紧密相关,但是同一主题.虚拟内存还有其他实现,例如分段.

Only the needed part of a program is resident in memory, typically - this is a topic called "paging". Virtual memory and paging are tightly related, but not the same topic. There are other implementations of virtual memory, such as segmentation.

我在这里可能是错的,但是我敢打赌,您发现难以解决的事情与虚拟内存的特定实现有关,最有可能是分页.没有一种方法进行分页-有很多实现,而您的教科书描述的实现可能与在像Linux/Windows这样的真实操作系统中出现的实现不同-可能存在细微的差异.

I could be assuming wrong here, but I'd bet the things you are finding hard to wrap your head around have to do with specific implementations of virtual memory, most likely paging. There is no one way to do paging - there are many implementations and the one your textbook describes is likely not the same as the one that appears in real OSes like Linux/Windows - there are probably subtle differences.

我可以大写一千篇关于分页的文章...但是我认为最好是针对该主题的另一个问题.

I could blab a thousand paragraphs about paging... but I think that is better left to a different question targeting specifically that topic.

这篇关于虚拟内存和物理内存之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆