Virtual Memory

June 18, 2019 (5y ago)

Virtual Memory

Advantages:

  1. Small memory spaces can be fully utilized, improving memory usage.
  2. Maximizing multiprogramming degree enhances CPU utilization (except in the case of thrashing).
  3. Reduced I/O transfer time, as not all program pages need to be loaded at once.

    Loading an entire program increases the number of I/O operations, which increases I/O time.

Demand Paging

image

Copy-on-Write

Fork() without Copy-on-Write

Fork() with Copy-on-Write

Copy-on-write (COW) is an optimization strategy where multiple callers share the same resources (e.g., memory or disk storage) until one tries to modify the resource, at which point a copy is made.

vfork() without Copy-on-Write (Virtual Memory Fork)

Effective Access Time (EAT) and Page Fault Ratio in Virtual Memory

To improve virtual memory efficiency, the goal is to reduce EAT by minimizing the page fault ratio.

Factors affecting page fault ratio:

  1. Page Replacement Algorithm.
  2. Number of allocated frames.
  3. Page size.
  4. Program structure.

Page Replacement

image

Page Replacement Policies:

Page Replacement Algorithms

FIFO (First In, First Out)

OPT (Optimal Page Replacement)

LRU (Least Recently Used)

Other algorithms include LRU Approximation, Second Chance, and LFU/MFU, with varying performance and implementation complexity.

Thrashing

Solutions to Thrashing:

  1. Reduce multiprogramming degree.
  2. Use Page Fault Frequency Control to allocate or reallocate frames based on page fault frequency.
  3. Employ the Working Set Model to predict and allocate the necessary number of frames for each process.

References