W8 - Memory Management (Part II) Flashcards
(52 cards)
What does os.exec() do?
Replaces current process image with new process. Process ID remains the same, but orginal code does not resume (function doesn’t return). This is done using one of the os.exec*() functions like os.execv() or os.execl().
Up to how many bytes are addressable with 32 bit addresses?
2^32 bytes = 4 gigabytes
Up to how many bytes are addressable with 64 bit addresses?
2^64 bytes = 16 exabytes.
What’s the formula for physical address?
Frame Number X 2^P + P-Bit Offset
What part of the computer uses page tables to translate pages to frames
CPU and Memory Management Unit (MMU)
Since each process gets its own page table, what happens to the current page table after a context switch?
You change which page table is active. A specific pointer points to the start of the page table. This will change in a context switch.
Imagine consecutive virtual addresses. Are they on consecutive pages? Are they on consecutive frames?
They are on consecutive pages, however they can be on any frame.
How does the CPU/MMU know where to find the process’s page table?
A register in the CPU points to the start of the page table.
How are page tables built? Why is it efficient?
An array where indices correspond to page number, and each index is a page table entry containing the frame number (and some flags). This is efficient compared to only storing entries for pages in use because we can jump to a page number and get the corresponding frame.
Where are page tables stored?
In memory.
How do flat (one level) page tables work?
One page table entry for each of the 2^n page numbers.
Translation Lookaside Buffer (TLB). What is it?
Operates as a cache for page number to frame number translations. Super fast.
If we find the page number in TLB, we get a TLB hit and we immediately know the frame number. If we don’t, we get a TLB miss and need to actually check page tables, then write to TLB.
Page Fault: When does it occur? What happens?
If we get a TLB miss, and the page table tells us it isn’t in memory.
We have to switch to the kernel and execute page fault handling code that lets us load the page to a frame.
What’s a page file / swap file?
Where we track pages that have been placed into disk. It’s protected by the OS.
In practice, do most processes need all their pages on hand in memory?
No. Certain features of programs are rarely used. Error handling code is not needed unless that specific error occurs (some errors are very rare). Arrays are often oversized, and we don’t need the entire array.
Benefits of loading portions of processes that are actually needed (and only when they are needed):
You can write programs for a much larger address space (virtual memory space) than physically exists on computer (so more efficient use of main mem). This is because each process is only using a fraction of its total address.
We check the page table, and the page isn’t in memory. What happens?
We have a page fault. This leads to an exception. This leads to the OS page fault handler being executed. We end up needing to perform a context switch for disk access. Page gets put on main memory, and page table is updated. We go back to the scheduler, which may reattempt to access the page, which should work.
Once the OS page fault handler loads the page from disk into memory, what crucial step must be performed?
Updating the page table.
How do we tell if a PTE corresponds to a page that isn’t in main memory)
One of the flags (a single bit) tells us. If the P bit says “page is not present in memory”, the remaining 31 bits can be used as a pointer for how to find the page in the ‘page file’ on disk.
What are the two types of page fault?
Minor: Page already in memory but not mapped to process’s address space.
Major: Page not in memory and must be loaded from disk.
What do we need to do if we’re trying to load a page from disk into main memory, but main memory is full?
Page replacement.
General Protection Fault
A program violates memory access rules enforced by CPU, resulting in a crash.
Core dump (current state written to file).
User mode GPF vs Kernel mode GPF
User mode GPF => Kernel terminates process
Kernel mode GPF => No way to recover. Blue screen of death or kernel panic. OS restarts.
Main cause of Kernel mode GPF
Drivers.