Operating Systems: Virtual Memory Flashcards
Why is full process swapping considered inefficient in memory management?
Full process swapping moves the entire process in and out of memory, including unused parts, which leads to wasted memory and CPU resources.
What types of program sections are rarely used and can remain unloaded initially?
What types of program sections are rarely used and can remain unloaded initially?
What is a more efficient alternative to full process swapping?
Partial loading, where only the necessary segments or pages are loaded into memory, while the rest remain on disk.
How can virtual memory allow a program to exceed physical memory limits?
By storing inactive pages on disk and only loading active ones into RAM, the program can appear larger than the available physical memory.
What is virtual memory in modern operating systems?
A system that separates logical memory (what a program sees) from physical memory (actual RAM), allowing for larger address spaces and dynamic translation of addresses.
List three key benefits of virtual memory.
Allows logical address space to exceed physical RAM
Enables on-demand loading, conserving memory
Supports more concurrent programs by swapping out inactive segments
What are the two main implementations of virtual memory systems?
Demand segmentation and demand paging.
What is demand paging in contrast to regular swapping?
Demand paging only loads a page into memory when it is accessed, reducing I/O and memory usage and improving performance.
What occurs when a program accesses a page that is not in memory?
A page fault occurs, prompting the OS to load the required page from disk.
What is the function of a lazy swapper in demand paging?
It defers loading a page into memory until it is actually needed by the program.
Describe the inefficiency of regular (old) memory swapping.
It loads the entire process, including rarely used code, requiring unnecessary memory and I/O overhead.
How does the new memory management approach using demand paging differ?
It uses on-demand loading and lazy swapping, loading only the pages needed at the time of access.
What is a page in the context of virtual memory?
A fixed-size block of data in a program’s logical address space, used to divide it into manageable chunks.
What is a frame in physical memory?
A fixed-size block of RAM that holds a page when it is loaded from disk.
What is the typical size of pages and frames?
Typically 4 KB, although it can vary depending on the OS and hardware.
What does the page table do in a virtual memory system?
It maps logical addresses to physical memory locations and indicates whether a page is currently in memory.
How does the page table use a valid/invalid bit?
The bit indicates if the page is currently in memory (valid) or not (invalid), guiding page fault handling.
What is the result of accessing a page with an invalid bit during address translation?
A page fault is triggered, and the page must be loaded from disk.
What steps are taken when a page fault occurs?
Check if the page reference is invalid
If valid, locate an empty frame
Load the required page from disk
Update the page table
Restart the instruction that caused the fault
What errors occur if the page reference is invalid?
Segmentation fault or access violation error.
What are the performance implications of pure demand paging at process start?
It is slow to get started, so loading initial pages proactively can improve performance.
What hardware support is required for demand paging?
Modified page table with valid/invalid bits
Swap space (secondary storage)
Ability to restart any instruction after a page fault
What is temporal locality in memory access?
The principle that recently accessed pages are likely to be accessed again soon.
What is spatial locality in memory access?
The principle that pages near a recently accessed page are likely to be used soon.