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.
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.
Can anyone help please?
(sorry if i used wrong words/terms anywhere. English is not my first language!)
Feel free to correct me if i did anything wrong.
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.
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?
It's just a guess. I really don't know what I'm talking about on this subject (and I don't feel like looking it up). I wish someone else would chime in here.
Originally Posted by Epitaph
you aren't missing anything. page table entries on 32-bit (x86) systems are 32 bits wide. the high 20 bits are the page aligned base address of the page, and the remaining 12 bits are flags for various purposes. look at this page for more info.
Originally Posted by oogabooga
the exception is when you have PAE (Physical Address Extension) enabled, in which case the page table entries become 64-bits wide, but the high dword's upper 28 bits are unused.