3

A machine-language instruction to load a 32-bit word into a register contains the 32-bit address of the word to be loaded. What is the maximum number of page faults this instruction can cause?

(Tanenbaum, OS, Q 44)

It looks like no brainer, it'll cause only 1 page fault. When it is trying to access the 32 bit word. (My theory regarding this question, please ignore it at will as it may contain many wrong or confused facts.)

Please tell me what is the correct solution of this question.

Tony Tannous
  • 14,154
  • 10
  • 50
  • 86
Neer
  • 203
  • 4
  • 13

2 Answers2

5

A single read instruction could trigger multiple page faults. Theoretically reading from an address which spans over two pages that are not present.

Tony Tannous
  • 14,154
  • 10
  • 50
  • 86
2

I found the accepted answer to be strange since I don't get how the page table may not be in main memory - how then would you even know where to look for it? :\

I surfed the Internet and found these two links and I think now I get the answer more or less sustainable.

The idea behind the answer is that address instruction can somehow (cross the boundary) belong to two page tables.

Thus, 2 pagefaults happen when both of these pages that contain the address are not in main memory and another 2 happen when you try to address the virtual address that is located in the word you previously tried to access - in total 4.

I'm still not quite sure about the answer but this version seems much more simpler (Occam's Razor) than the version of the accepted answer that supposes that the page table may not be in main memory. Hope that'll help.