Virtual Memory # MCQs Practice set

Q.1 What is the main purpose of virtual memory in an operating system?

To increase CPU speed
To extend physical memory using disk
To manage cache memory
To reduce file size
Explanation - Virtual memory allows the system to use disk space as an extension of RAM, enabling larger programs to run than physical memory alone could support.
Correct answer is: To extend physical memory using disk

Q.2 Which hardware component is essential for implementing virtual memory?

Cache
Translation Lookaside Buffer (TLB)
Disk controller
DMA controller
Explanation - The TLB is used to speed up virtual-to-physical address translation, which is central to virtual memory implementation.
Correct answer is: Translation Lookaside Buffer (TLB)

Q.3 Page faults occur when:

A program accesses data in cache
A program accesses data in RAM
A program accesses a page not in memory
The CPU executes an invalid instruction
Explanation - A page fault happens when the referenced page is not present in main memory and must be loaded from disk.
Correct answer is: A program accesses a page not in memory

Q.4 Which of the following is NOT a page replacement algorithm?

FIFO
LRU
Optimal
Round Robin
Explanation - Round Robin is a CPU scheduling algorithm, not a page replacement algorithm. FIFO, LRU, and Optimal are valid page replacement methods.
Correct answer is: Round Robin

Q.5 What does 'thrashing' mean in virtual memory?

CPU overheating
Excessive swapping between RAM and disk
Too many cache misses
A program crashing
Explanation - Thrashing occurs when the system spends more time swapping pages than executing processes, leading to performance degradation.
Correct answer is: Excessive swapping between RAM and disk

Q.6 The principle of locality of reference is crucial in virtual memory because:

It reduces CPU cycle time
It predicts that programs access a small portion of memory at a time
It increases disk I/O speed
It avoids cache misses
Explanation - Locality of reference means programs typically use a small set of memory locations repeatedly, which makes paging efficient.
Correct answer is: It predicts that programs access a small portion of memory at a time

Q.7 In demand paging, pages are loaded into memory:

Before execution starts
As they are needed
Only at compile time
Only at system boot
Explanation - Demand paging loads pages into memory when they are referenced, reducing initial load time and memory usage.
Correct answer is: As they are needed

Q.8 Which replacement algorithm suffers from Belady’s anomaly?

FIFO
LRU
Optimal
Clock
Explanation - Belady’s anomaly is when increasing the number of page frames leads to more page faults, and it is observed in FIFO.
Correct answer is: FIFO

Q.9 The working set model is used to:

Reduce CPU load
Prevent thrashing
Increase cache hits
Improve disk scheduling
Explanation - The working set model tracks the set of pages a process is currently using to ensure enough frames are allocated, preventing thrashing.
Correct answer is: Prevent thrashing

Q.10 The effective access time in virtual memory depends on:

TLB hit ratio
Cache size
CPU speed
Disk block size
Explanation - Effective access time depends largely on whether memory references are satisfied from the TLB or require additional memory access.
Correct answer is: TLB hit ratio

Q.11 The page table maps:

Logical addresses to physical addresses
Processes to threads
Files to memory
Disks to RAM
Explanation - The page table translates logical (virtual) addresses into physical memory addresses.
Correct answer is: Logical addresses to physical addresses

Q.12 What is a major disadvantage of a single-level page table?

High TLB miss rate
Large memory requirement
Slow CPU speed
Increased disk fragmentation
Explanation - Single-level page tables require large contiguous memory, especially for systems with large virtual address spaces.
Correct answer is: Large memory requirement

Q.13 Which is an advantage of using virtual memory?

Faster disk I/O
Allows execution of programs larger than RAM
Eliminates context switching
Increases CPU frequency
Explanation - Virtual memory enables execution of programs that do not fit entirely in physical RAM by swapping parts to disk.
Correct answer is: Allows execution of programs larger than RAM

Q.14 In virtual memory, a 'frame' refers to:

A block of physical memory
A segment of a program
A disk partition
A TLB entry
Explanation - Physical memory is divided into equal-sized blocks called frames, where pages from virtual memory are loaded.
Correct answer is: A block of physical memory

Q.15 Which of the following is used to handle page faults?

Memory management unit
Disk scheduler
Page replacement algorithm
Cache controller
Explanation - When a page fault occurs, the OS uses a page replacement algorithm to decide which page to evict from memory.
Correct answer is: Page replacement algorithm

Q.16 The Optimal page replacement algorithm replaces:

The most recently used page
The least recently used page
The page not used for the longest time in the future
A random page
Explanation - Optimal replacement replaces the page that will not be used for the longest period, minimizing future page faults.
Correct answer is: The page not used for the longest time in the future

Q.17 Which of the following statements about virtual memory is FALSE?

Virtual memory increases logical address space
Virtual memory can be larger than physical memory
Virtual memory guarantees faster execution
Virtual memory enables demand paging
Explanation - Virtual memory may actually slow execution due to page faults; it is designed for flexibility, not speed guarantees.
Correct answer is: Virtual memory guarantees faster execution

Q.18 Segmented memory management differs from paging because:

Segments are fixed size, pages are variable size
Pages are fixed size, segments are variable size
Both are variable size
Both are fixed size
Explanation - Paging uses fixed-size blocks, while segmentation divides memory into variable-size segments based on logical program structure.
Correct answer is: Pages are fixed size, segments are variable size

Q.19 Which of the following reduces the size of page tables in large address spaces?

Associative mapping
Multi-level paging
Swapping
Segmentation
Explanation - Multi-level paging breaks the page table into smaller parts, reducing memory overhead for large virtual address spaces.
Correct answer is: Multi-level paging

Q.20 What does 'resident set' mean in virtual memory?

Pages currently stored on disk
Pages currently loaded in RAM
All virtual pages of a process
All shared memory pages
Explanation - The resident set of a process is the set of its pages that are currently in physical memory.
Correct answer is: Pages currently loaded in RAM

Q.21 In virtual memory, the address generated by the CPU is called:

Physical address
Virtual address
Frame address
Disk address
Explanation - The CPU generates virtual addresses, which are then translated into physical addresses by the MMU.
Correct answer is: Virtual address

Q.22 The Clock page replacement algorithm is a practical implementation of:

FIFO
LRU
Optimal
Random
Explanation - The Clock algorithm approximates LRU (Least Recently Used) replacement using a circular buffer and reference bits.
Correct answer is: LRU

Q.23 Page size in virtual memory is typically:

Variable per process
Fixed and power of 2
Equal to disk block size
Randomly chosen
Explanation - Page size is fixed and usually chosen as a power of 2 for efficient address translation and alignment.
Correct answer is: Fixed and power of 2

Q.24 Internal fragmentation in virtual memory occurs when:

A page is only partially used
Frames are too small
Pages are swapped too often
Disk blocks are too large
Explanation - Since pages are fixed size, not all memory inside a page may be used, leading to internal fragmentation.
Correct answer is: A page is only partially used

Q.25 Which of these best defines demand segmentation?

Loading entire segments at once
Loading only needed segments into memory
Swapping frames to disk
Using both paging and segmentation
Explanation - Demand segmentation loads segments only when needed, similar to demand paging but at the segment level.
Correct answer is: Loading only needed segments into memory