简体   繁体   English

如何从虚拟地址确定页码?

[英]How do I determine the page number from the virtual address?

I am looking for help with the following homework question:我正在寻求以下作业问题的帮助:

It is assumed that a program has a virtual space of 1200 words.假设一个程序有1200个字的虚拟空间。 Consider the following series of virtual addresses:考虑以下一系列虚拟地址:

 60; 222; 160; 910; 450; 345; 412; 10; 180; 20; 443; 766; 812.

Give the sequence of the referenced page numbers, assuming that each page has 200 words.给出参考页码的顺序,假设每页有 200 个单词。

How does the total virtual space relate to the 200 word pages?总虚拟空间与 200 字页面有什么关系? Does this mean the memory has 6 pages?这是否意味着 memory 有 6 页? How do I determine the page number from the virtual address?如何从虚拟地址确定页码?

Just looking for help to understand the steps, not a full solution thanks.只是寻求帮助以了解这些步骤,而不是完整的解决方案,谢谢。 I have looked through many examples and have had trouble seeing a repeatable formulaic way to do this.我看过很多例子,但很难找到一种可重复的公式化方法来做到这一点。 I have trouble understanding long text chunks and prefer mathematical formulas but available answers seem to have very wordy explanations.我很难理解长文本块并且更喜欢数学公式,但可用的答案似乎有非常冗长的解释。

I'm thinking virtual address #60 on page 1 because it is less than 200. Then after that, 222 would be on page 2 since ceiling(222/200) = 2 .我在想第 1 页上的虚拟地址 #60,因为它小于 200。然后,222 将在第 2 页上,因为ceiling(222/200) = 2

  1. Is that correct?那是对的吗? Is ceiling(virtual address/page size) the right way to do it? ceiling(virtual address/page size)是正确的方法吗?

  2. What do I make of the 1200?我用 1200 做了什么? Would a virtual address of 1201 be invalid for a virtual space that size?对于这样大小的虚拟空间,1201 的虚拟地址是否无效?

The formula is floor (virtual address / page size) for systems that use positional notation (start at zero) and ceiling (virtual address / page size) for systems that are 1-based (start at 1).对于使用位置表示法(从零开始)的系统,公式是下限(虚拟地址/页面大小),对于基于 1(从 1 开始)的系统,公式是上限(虚拟地址/页面大小)。

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

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