# Page Tables Memory Size

• 08-28-2012
Epitaph
Page Tables Memory Size
First off, sorry for posting that thread here. It hasn't to do with C programming, but while i was desperately searching for this matter, i came to find one similar question right here, in this sub-forum.
I suppose i could post that in Windows/Linux subforum.
Excuse my ignorance.

I'm currently reading for Operational Systems and i have the following question, which i'm not sure i've found the right answer.

So here we go :

A 32bit Machine uses paging with a page size of 4KB. Each data entry at the page table has 8 Bytes size.
A process has
Code Size : 653789 Bytes
Stack Size : 23934 Bytes
Data Size : 178934 Bytes

How much memory must be provided for the page table if :
a) it is a one level page table
b) it's a 2 level page table, where the first 10bits are used to adress the page table of the highest level (level 1).

Now i think i've found some stuff, but i'm not quite sure.

For a),since the page size is 4KB (2^12), i need to multiply the data entry size with 1024.

But for b :
First i convert the Code,Stack and Data sizes to powers of 2.
So
Code Size = 653,789/1024 = 638,4 = 639KB
Stack Size = 23.3 = 24 KBytes
Data Size = 174,7 = 175 Kbytes

But then i'm not sure of what to do.
(sorry if i used wrong words/terms anywhere. English is not my first language!)

Feel free to correct me if i did anything wrong.
• 08-28-2012
oogabooga
Hopefully someone who has taken an OS course much more recently than I have can answer this, but the way I see it for question a)

Code Size : 653789 Bytes Needs 160 pages (at 4K per page).
Stack Size: 23934 Bytes Needs 6 pages.
Data Size : 178934 Bytes Needs 44 pages.
Total: 210 pages.

8 bytes per page table entry: 8 * 210 = 1680 bytes.

But maybe I'm missing something. For example, I'm not sure why the page table entries are 64-bits on a 32-bit machine.
• 08-28-2012
Epitaph
Thanks for the answer (by the way, awesome nickname hahaha :D)!

As for the 2nd case, i know that each line in the first table points to a certain 4K table on the 2nd level page tables. But i can't figure if we'll also count the size of the first table too.

So for the 2nd case, i think it's 1 table on level one that shows to 1 table on the 2nd level!
So it's 4096 Bytes on the second level. But you also have to add the size of the first level to that?
• 08-28-2012
oogabooga
Quote:

Originally Posted by Epitaph