Thread: Page Tables Memory Size

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    2

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

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    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.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  3. #3
    Registered User
    Join Date
    Aug 2012
    Posts
    2
    Thanks for the answer (by the way, awesome nickname hahaha )!

    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?

  4. #4
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Quote Originally Posted by Epitaph View Post
    Thanks for the answer
    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.
    The cost of software maintenance increases with the square of the programmer's creativity. - Robert D. Bliss

  5. #5
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by oogabooga View Post
    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.
    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.

    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Database size, Tables , Server, BCB6
    By Leite33 in forum Windows Programming
    Replies: 0
    Last Post: 11-06-2006, 12:17 AM
  2. In Memory Tables
    By koodoo in forum C++ Programming
    Replies: 2
    Last Post: 07-06-2006, 02:49 AM
  3. help with memory size
    By cBegginer in forum C Programming
    Replies: 3
    Last Post: 03-19-2006, 10:28 AM
  4. [C] Get the page-size in memory
    By BianConiglio in forum Windows Programming
    Replies: 2
    Last Post: 12-18-2004, 05:12 AM
  5. Memory size
    By a_learner in forum C Programming
    Replies: 4
    Last Post: 10-08-2001, 08:10 PM