内存非常便宜时虚拟内存的重要性 [英] Importance of Virtual Memory when memory is very cheap

查看:105
本文介绍了内存非常便宜时虚拟内存的重要性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编程采访中,这个问题被问给了一位大四学生. 据我说,由于软件访问的内存大小正在增加,因此内存可能很快就会用完.因此,在这种情况下,如果我们使用交换,则效率低下.因此我们会选择虚拟内存,因为它会将磁盘中的内存映射到主内存.

但是,如果我们可以拥有非常大的内存,那么虚拟内存会有用吗? 并请告知以上答案是否需要修改.

解决方案

虚拟内存仍然很重要.主要原因之一是它提供了保护.尽管这可以通过提供类似于x86段的内存保护单元(而不是提供虚拟内存的内存管理单元)来实现,但虚拟内存提供的下一个重要内容却存在问题,这些重要内容可以共享并映射内存.仅使用一个内存保护单元和类似的内存映射文件,尝试执行诸如共享内存段之类的事情(例如在System V IPC共享内存中)是非常困难的.另外,如果您只有一个内存保护单元,那么动态限制进程的内存空间就很难了,因为您只能使用物理上连续的内存.

简而言之,另一种看待方式是虚拟内存提供了操作系统为Unix之类的系统以及大多数两个分层特权级系统中的进程提供的基本抽象之一.虽然此抽象的最初部分是使它看起来好像该进程可以访问的内存多于系统可能拥有的内存,但虚拟内存提供的其他抽象不能简单地通过拥有大量RAM来克服.

对于逻辑与虚拟,虽然这些词对于不同的体系结构可能具有不同的含义,但我建议 解决方案

Virtual memory is still important. One of the main reasons is that it provides protection. While this could be accomplished with a memory protection unit which provides something similar to x86 segments as opposed to a memory management unit which provides virtual memory, this has problems with the next important things virtual memory provides which are sharing and having things memory mapped. Trying to do something such as a shared memory segment (as in the System V IPC shared memory) is very difficult with just a memory protection unit and similar for memory mapped files. Also if you have only a memory protection unit dynamically increasing the memory space of a process is difficult has you are limited to physically contiguous memory.

In short another way to look at this is virtual memory provides one of the fundamental abstractions that an operating system provides to a process in Unix like systems and in most two tiered privilege level systems. While initial part of this abstraction was to make it appear as if the process had access to more memory than the system might have there are other abstractions that virtual memory provides that aren't overcome by simply having lots of RAM.

As for logical vs virtual while the words can have different meanings for different architectures I recommend this SO question.

这篇关于内存非常便宜时虚拟内存的重要性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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