18. Introduction to Paging Flashcards
What are page frames?
An array of fixed-sized slots in the physical memory
What is a page?
A fixed-size unit of memory
What is a page table?
A per-process data structure that store address translations of virtual pages to physical pages
How does address translation in pages work?
We have two components: Virtual Page Number (VPN) and offset
The VPN is to indicate which page number is it
The offset points to the specific entry of the chosen page
All we have to do it replace the VPN with the Physical Page Number (PPN) and use the offset to read the data.
What is page table entry (PTE)?
One entry in the page table that indicates the translation between virtual pages to physical pages. Typically 4KB.
How to calculate the VPN and offset bit sizes.
Address space divided by page size = VPN
Eg. 32 bit = 2 ^ 32 size, 4KB = 4096 size = 12 bit
Therefore, VPN size is 20 bits and offset is 12 bits (32 - 20)
What are the components of a page table entry (PTE)?
- Translation from virtual address to physical frame
- Valid bit - indicates whether a particular translation is valid. (Unused entries will be indicated as invalid)
- Protection bit - indicates whether the page can be read from, written to, or executed from
- Present bit - indicates whether the page has been swapped out
- Dirty bit - indicates whether the page has been modified since it was brought into the memory
- Reference bit - indicates whether the page has been referenced in the past and should be cached
What are the advantages of paging?
- Does not lead to external fragmentation
- Flexible enough to enable the sparse use of virtual addresses
What are the disadvantages of paging?
- Slower - more memory access
- Memory waste - need to store page table data