If I have a system with a 2 level page table such that each page is 4096 Bytes, 8 byte page table entries, and 4096 byte page tables at each level, what would the page table size at least have to be for a program with access to a 1000 pages of memeory?
I figured out that each page table can have 512 entries so we need at least 2 page tables but how do I account for the 2 levels.
Related
A system with 2-level page table in the form of (p1, p2, offset), and the content of page table
No 1 of level 2 is: {(32, v),(45, i),(12, v),(5, v),(34, i)}. Suppose the frame size is 4KB; the
address register is 32 bit, the number of bits for level 2 (p2) of the address register is 10.
Given a reference =4225332, calculate its physical address, e.g., 12764?
I don't understand the meaning of page table No 1 of level 2. In some problems, it could be No 0 or No 2. Could you help me explain that and solve this problem? Thanks a lot!
Suppose a system has:
20-bit virtual addresses,
1024 byte pages,
24-bit physical addresses,
4 byte page table enties,
a page table base pointer set to physical (byte) address 0x1000,
a single-level page table structure.
Based on the above information, what is the address at which the page table entry for the virtual address 0x1000 is stored? (Note that page table entries are larger than one byte.) Write your answer as a hexadecimal number.
1024 (2^10) byte pages -> page offset = 10
virtual address 0x1000 -> 100 0000000000
VPN: 100 -> 0x4
PTE address = 0x1000(page table base pointer) + 0x4(VPN)* 4(size of PTE) = 0x1010
So the correct answer is 0x1010.
I'm currently reading a text book on xv6, and understand this so far ...
Virtual Address: First 20 bits to index into a PTE. The PTE takes these 20 bits and turns them into a Physical Page Number: PPN. The remaining 12 bits are used for offset, which will be the same in both virtual and physical addresses.
Paging: Paging hardware uses first 10 bits of 20 bits in the virtual address to select a page directory entry (PDE). If a PDE is present, uses next 10 bits of virtual address to select a page table entry (PTE). Something like this ...
00 0000 0011 | 00 0000 0010 | 0000 0000 0101
Page Dir. (3) | Page Table E. (2) | Offset (5)
Question: Is the PPN showed in the diagrams the same all across? I also know the difference between a page directory and page table entry is only by 1 bit, which is set to 0 or 1 depending if you are at page directory or table. Is the PPN common between all 3 then? (Physical Address, Page Table, Page Directory).
Hopefully, this answers your question. If you access a 32-bit address, 12-bits are saved for the offset into the page. They play no part in address translation.
The CR3 register points to a page table directory. Although not specified in your diagram, I believe this points to a physical page frame. That page frame contains an array of directories. The top 10 bits in your address are an index into that directories.
So now you have a structure like the one in your diagram. That structure contains a pointer to a physical page frame (PPN) containing a page table. Again this is physical address that would be padded with zeroes. You use the value in the PPN field to find the page table.
Your page table is an array of structures that look just like the directory. What is misleading in your diagram is that the D bit may or may not be set in a page table while it is always clear in a directory. The next 10 bits in your address are an index into this table. Use those to locate the desired page table entry.
As before you have a PPN. On this second iteration, this is a pointer to a physical address BUT now it is the actual memory page you want to access. Pad the 20 bits of the PPN with zero and add the lower 12 bits of your address and you have the physical address.
if i have a Virtual Address: 0xF3557100 , how do i convert it to Physical Address and what are the Values of Offset, Page Directory and Page Table ?
The PTE (page table entry) for that address has the value 0x87124053
thnx
Sadly, what you are asking is system dependent. You would need to know the size of the page to begin with.
In the simplest case, the lowest order bits corresponding to the page size are the offset and the remaining high order bits specify the page table entry.
You say that you have the value of he page table entry. You then need to know the structure of the page table entry. Some part of that will indicate the physical address. Other parts will define page attributes.
In short, we'd need to know a whole lot more information.
In general from this info you can not translate a VA to PA.
Each architecture has some constant value for PAGE_SHIFT. as your address is 32 bit, most of such architecture has 12 bit PAGE_SHIFT value.
this value determines the offset value so your offset value is 12 bits.that also means your page size is 4096 bytes. even though a architecture can support more than one value for PAGE_SHIFT, we take case of 12 bits offset which is usually default value in most systems making page of 4096
PTE contains address of the page frame/number along with other status and protection information.Lower 12 bits in PTE are used for status and protection while other 20 bits are used for PPN. as a principle virtual frame number is mapped to physical frame number and offset is same in both. so exclude lower most 12 bits from PTE and append 12 lower most bits from va.
so offset from va is 0x100 so physical address is 0x87124100
according to 10-10-12 rule (there is no general rule for this division)
offset = 12 bits
page table = page directory=10 bits
now you CAN easily calculate relevant bits value from given address.
1111001101 0101010111 000100000000
page directory offset = 1111001101
page table offset = 0101010111
page offset = 000100000000
I want to know the size of my Table (postgresql). I make this query:
select pg_size_pretty(pg_table_size('mytable'));
Result: 8192 bytes
Then, I add 4 rows and the result is the same (8192 bytes).
What am I doing wrong? What am I missing?
Thanks a lot...
Postgres puts records in fixed-size pages, which are 8kB each by default. Storage is allocated one page at a time. Once you add enough rows to reach your table's fillfactor, it will add a second block, and the size will jump to 16384 bytes.