1

My book had the following image:

enter image description here

And a question of how many PTE's are there in L2 (or L1), the answer was 16 = 2^4 but why is that?

In the question it's given that each PTE size is 2 bytes so the answer should be 2^4/2 = 8 Since L2 index holds where we will point to. For example if it's 2 then it point to second half of the first PTE and not the second PTE.

What am I missing here?

1 Answers1

1

You are overthinking. There are 4 bits used to index the L1 page table entry, so there are 2^4 possible values for this index and thus 2^4 possible page tables entries.

The size of a page table entry is not relevant to this question. It is asking "how many", not "how large".

Nate Eldredge
  • 48,811
  • 6
  • 54
  • 82
  • You can claim that 0 points to first PTE and 1 to second PTE... Since PTE size is 2 not 1. unless there is some external component to multiply index by 2 16 is wrong answer. –  Jul 20 '21 at 22:32
  • @John: The **index** of a page table entry is not the same as its **address**. To get the address, you would multiply the index by the size of a page table entry (here 2 bytes, so a simple left shift by 1 bit) and add it to the page table base (typically stored in a special register). That is part of what the MMU would do in page translation; I wouldn't call the MMU an "external component" though. – Nate Eldredge Jul 20 '21 at 22:34
  • Oh so MMU does the multiplication? This makes everything clear, my point was if non was doing the multiplication then this doesn't make sense. Please take a look at my many questions in this field as I'm struggling to get answers to understand what wasn't found on the web. –  Jul 20 '21 at 22:39