What are three guiding principles of Memory Management system?
What are the three tasks of memory management? (What does mem mgmt DO?)
Describe page-based memory management
(this is the most common method)
Describe segment-based memory management
(this is less common than page-based mem mgmt)
How does hardware support memory management?
What is the memory management unit?
How are hardware registers used in the address translation process?
Describe the Translation Lookaside Buffer
The TLB is a hardware cache of valid virtual to physical address translations. This avoids the need to perform translation and speeds things up.
What performs translation of virtual to physical addresses, hardware or software? How does this affect the design of memory management system?
Hardware! The hardware therefore dictates what kinds of memory management are supported (paging vs segment, what kind of pages, etc.)
What performs allocation of memory, hardware or software? What does this mean for design of mm system?
Software! This means the system can be more flexible.
What performs replacement policy for memory management, hardware or software?
Software! This makes it more flexible.
What are page tables and how do they work?
Describe the mapping of virtual to physical addresses via the page table
Because we only need to map the first entry in each page to the first entry in each page frame, the page table only requires the Virtual Page Number (VPN), i.e., the first part of the virtual address.
We use the VPN as an offset in the page table to find the Physical Frame Number (PFN).
Once we have that, we append the remainder of the virtual address after the VPN (the offset) to the PFN.
What is “allocation on first touch”?
This means that we only allocate physical memory to an object when we first try to access it. This prevents the allocation of physical memory to objects that are never used.
What happens when pages go unused for a long time?
The associated physical page frames are reclaimed and eventually reassigned to other pages. The data stored in the page frame is pushed to disk.
How do page tables help detect reclaimed page frames?
In addition to the mapping from VPN to PFN, the page table also includes bits that tell the mem mgmt system info about the validity of an attempted access.
If the page is in physical memory, the bit is 1, otherwise 0.
If MMU sees that bit is zero, it will raise a fault and the OS will take over and decide how to handle it.
As long as this was a valid address is being accessed, the data will be brought back into physical memory, likely at a different location. Page map is updated.
How many page tables are maintained?
One per process
How are page tables involved in a context switch?
On a context switch to a new process, the OS must switch to the page table for that process.
Describe a generic page table entry
A page table entry will include:
What is the common page size?
4kb
Describe the storage issue for page tables
Page table has n entries, where n is the number of virtual page numbers in virtual address space. Each entry holds PFN + flags, 8 bytes oughtta do it for 64-bit arch.
The number of entries depends on the size of the addresses and page size. On 64-bit architecture with 4 kb pages, that means 2^64 / 4 kb = 2^64 / 2^12 = 2^52 entries. If each entry is 8 bytes long, that’s 2^52 * 8 bytes = 32 PB!
Per process!
How do you solve the page table storage size issue?
By using hierarchical page tables instead of flat!
Describe Hierarchical Page Tables
An outer page table (or top page table, page table directory) points to internal page tables.
Internal page tables are only allocated for valid virtual memory regions. Blank regions don’t get internal tables.
On malloc, a new internal page table may be created.
What does the virtual address look like for hierarchical page tables?
The first element indexes the outer page table, the second element indexes the internal page table, and the offset is still at the end (like in a regular virtual address)