简体   繁体   English

虚拟 memory 中的地址转换

[英]Address translation in virtual memory

I'm watching these series and I don't understand what is the 12 bits page offset (I only raise 2^12-1 and got 4Kb and I though it is the size of the page itself but I'm not sure it's correct).我正在看这些系列,但我不明白12 位页面偏移量是什么(我只提高了2^12-1并得到了4Kb ,虽然它是页面本身的大小,但我不确定它是否正确)。 Also I don't understand what is the virtual page number .另外我不明白什么是虚拟页码 I've watched all the series 1-6 from the guy, and did understand what he presented.我看过这个家伙的所有系列 1-6,并且确实理解他所呈现的内容。 I also enjoy the explanation with the houses and streets but I still don't get it.我也喜欢对房屋和街道的解释,但我仍然不明白。

This is the picture he explains:这是他解释的图片: 在此处输入图像描述

OK - the diagram you posted is a very good description of "virtual memory".好的-您发布的图表是对“虚拟内存”的很好描述。

With regard to your most recent question:关于您最近的问题:

Q: What does the page offset?问:页面偏移量是多少?

  1. When your program wants to access memory, it uses a "Virtual Address".当您的程序想要访问 memory 时,它使用“虚拟地址”。

  2. "Virtual addresses" map to "Physical addresses". “虚拟地址”map 到“物理地址”。

    The mapping involves a combination of "page #" (what "page" does the data we're interested in reside in?) and an "offset".映射涉及“page #”(我们感兴趣的数据驻留在哪个“page”中?)和“offset”的组合。

  3. The "offset" is simply the location within a page where our data resides. “偏移量”只是我们数据所在页面的位置。

    Offset "0" is the first byte in the page.偏移量“0”是页面中的第一个字节。

    Offset "9" is the 10th byte in the page.偏移量“9”是页面中的第 10 个字节。

    Etc. Etc.等等等等。

Perhaps part of your confusion is:也许您的部分困惑是:

Q: Why do we need "virtual memory" (and pages and address mappings) in the first place???问:为什么我们首先需要“虚拟内存”(以及页面和地址映射)???

Consider an operating system like DOS.考虑像 DOS 这样的操作系统。 There is no virtual addressing, there are no "pages".没有虚拟寻址,没有“页面”。 Everything is just "physical memory".一切都只是“物理记忆”。

In DOS, a 16-bit address IS the physical address.在 DOS 中,16 位地址物理地址。 It points directly to a specific location - a specific byte - in physical memory.它直接指向物理 memory 中的特定位置 - 特定字节。 The "address" IS the "offset", from physical memory location "0". “地址”是“偏移量”,从物理memory位置“0”开始。 (Strictly speaking, a DOS "address" is actually the 16-bit offset into the current "segment", which is in the Intel 8086 "segment register". But we digress...) (严格来说,DOS“地址”实际上是当前“段”的 16 位偏移量,位于 Intel 8086“段寄存器”中。但我们离题了......)

One of the problems with a simple, non-paged system like DOS is RAM limits .像 DOS 这样简单的非分页系统的问题之一是RAM 限制 Another problem is that any DOS application can access - and potentially corrupt - the memory used by any other active DOS application (including DOS TSRs).另一个问题是任何 DOS 应用程序都可以访问 - 并且可能损坏 - 任何其他活动 DOS 应用程序(包括 DOS TSR)使用的 memory。

Virtual Memory solves these - and many other - problems. 虚拟 Memory解决了这些以及许多其他问题。 Even though "paging" introduces extra complexity, systems that support virtual memory can be much more powerful, robust and secure.尽管“分页”引入了额外的复杂性,但支持虚拟 memory 的系统可以更加强大、稳健和安全。

Q: Does that help?问:这有帮助吗?

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

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