两级分页系统中每一级的页表项是否必须具有相同的大小?

发布于 2024-10-16 07:30:17 字数 598 浏览 2 评论 0原文

假设您有一个具有 32 位逻辑地址的两级分页系统,并且页面偏移量已预先确定为 12 位。这为页码留下了 20 位。我可以在网上和教科书中找到的所有示例都显示页码,然后将其分为 2 个块,每块 10 个,这样虚拟地址看起来像这样:

[ p1: 10-bits | p1: 10-bits | p1: 10-bits p2:10 位 | offset: 12-bits ]

两个页码都必须是 10 位吗?例如,可以改为:

[ p1: 8-bits | p1: 8-bits | p1: 8-bits | p1: 8-bits p2:12 位 | offset: 12-bits ]

那么使用奇数位作为页码怎么样,例如:

[ p1: 9-bits | offset: 12-bits ] p2:11 位 | offset: 12-bits ]

我理解将它们均匀地分割,使一切干净有序。我只是想弄清楚它在技术上是可行的,以及以不同的方式做是否有任何缺点/好处。


*全面披露:这个问题本身不是作业问题,而是在尝试解决作业问题时出现的问题。不试图让任何人为我做我的工作。只是想了解什么是可能的,以及以一种或另一种方式这样做是否有任何优点/缺点。

Let's say hypothetically you have a two-level paging system with a 32-bit logical address and the page offset has been predetermined to be 12-bits. This leaves 20-bits for the page numbers. All the examples I can find online and in textbooks show the page numbers then split into 2 blocks of 10 such that the virtual address looks something like this:

[ p1: 10-bits | p2: 10-bits | offset: 12-bits ]

Do both page numbers have to be 10-bits? For example, can it be this instead:

[ p1: 8-bits | p2: 12-bits | offset: 12-bits ]

And what about using an odd number of bits for the page numbers, such as:

[ p1: 9-bits | p2: 11-bits | offset: 12-bits ]

I understand splitting them evenly, makes everything clean and orderly. I'm just trying to figure out what it is technically possible and if there are any drawbacks/benefits to doing it differently.


*Full Disclosure: This question itself is not a homework problem, but a question that arose while trying to solve a homework problem. Not trying to get anyone to do my work for me. Just trying to understand what is possible and if there are any advantages/disadvantages of doing it one way or the other.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回眸一遍 2024-10-23 07:30:17

除了简化实现之外,没有理由要求它们具有相同的大小。事实上,在某些系统(例如 x86)中,您显示的 p2 字段可以是某些页面而非其他页面的 offset 的一部分,以允许多种页面大小。

There is no reason that they need to be the same size other than to simplify the implementation. In fact, in some systems (such as x86), the p2 field you show can be part of the offset for some pages and not others, to allow multiple page sizes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文