Week 8: Virtual Memory Flashcards
What is the basic principle behind virtual memory?
At any given time, only the code and data needed for the current instruction must be in physical memory.
How does the operating system handle references to virtual memory and not to physical memory?
By recognizing them and fetching the required data into memory.
What is logical address space?
The address space that a program assumes is available, mapped to physical memory during execution.
How large is the logical address space for a 32-bit processor?
4GB (2³² bytes).
What are pages and page frames?
Pages are blocks of memory in logical address space, and page frames are their counterparts in physical memory.
Why are pages and page frames the same size?
To simplify mapping between logical and physical memory.
What role does the memory management unit (MMU) play in address translation?
It intercepts logical addresses and maps them to physical addresses using a page table.
What is a page table?
A data structure that stores the mapping between page numbers and page frame numbers.
Why are multilevel page tables used?
To reduce the size of page tables for systems with large address spaces.
How does multilevel indexing work?
It splits the page table into layers, reducing the memory needed for storing the entire table.
What is a page fault?
An interrupt generated when a process accesses a page not currently in physical memory.
What is demand paging?
Loading a page into memory only when it is needed.
What is the goal of page replacement algorithms?
To decide which page to remove from memory to make space for a new page.
How does the optimal page replacement algorithm work?
It replaces the page that will not be used for the longest time in the future.
Why is the optimal algorithm impractical?
A: It requires knowledge of future memory references.
How does the Not-Recently-Used (NRU) replacement algorithm work?
It records if a page is referenced or modified and saves it in the page table. The reference flag is reset at regular intervals (e.g., system clock interrupt). When a page fault occurs the pages are examined:
- Class 0: not referenced, not modified,
- Class 1: not referenced, modified,
- Class 2: referenced, not modified,
- Class 3: referenced, modified
A random page of the lowest available class is chosen
How does the FIFO algorithm work?
It removes the oldest page in memory, based on insertion order.
What is the disadvantage of FIFO?
It may remove frequently used pages.
How does the second chance algorithm improve FIFO?
It checks if the oldest page has been recently referenced and gives it another chance if it has.
What is the clock algorithm?
A circular implementation of second chance that uses a pointer to track pages.
How does LRU approximate the optimal algorithm?
By replacing the page that has not been used for the longest time.
What are the challenges of implementing LRU?
It requires keeping track of the last usage time for every page.
What factors influence the design of virtual memory systems?
Page size, prepaging strategies, and maintaining free pages.
What is a paging demon?
A process that periodically frees old pages to maintain a pool of free pages.