Search code examples
memoryfifolruvirtual-address-spacepage-fault

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. 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.

How does the total virtual space relate to the 200 word pages? Does this mean the memory has 6 pages? 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. Is that correct? Is ceiling(virtual address/page size) the right way to do it?

  2. What do I make of the 1200? Would a virtual address of 1201 be invalid for a virtual space that size?


Solution

  • 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).