Skip to main content

Virtual memory management; thrashing

Short answer

Virtual memory lets processes run with partial address space in RAM using demand paging. Thrashing is a state where insufficient frames cause constant page faults, collapsing CPU utilization; it is prevented by working-set model or page-fault frequency control.

What do you mean by virtual memory management? Explain about thrashing.

Virtual memory management

Virtual memory is a technique that lets a process run even when only part of it is in main memory. The logical (virtual) address space can be much larger than physical memory; the OS keeps the complete program on disk (swap area) and brings pages into memory when needed. The programmer sees a large, contiguous memory.

How it works (demand paging):

  1. The virtual address space is divided into pages; physical memory into frames.
  2. The MMU translates virtual to physical addresses using the page table (with a TLB cache).
  3. A reference to a page not in memory causes a page fault; the OS loads the page from disk, using a page replacement algorithm (FIFO, LRU, optimal, clock) if no frame is free.
  4. Management issues: page size, allocation of frames, replacement policy, working set, and load control.

Benefits: programs bigger than RAM can run, more processes can be in memory (higher CPU utilization), less I/O at start, memory protection and sharing. Cost: page-fault overhead; if faults are frequent the system slows down.

Thrashing

Thrashing is a state in which the system spends most of its time moving pages between disk and memory instead of executing processes. A process whose allocated frames are fewer than its working set faults continually; CPU utilization falls; the scheduler, seeing low utilization, admits more processes, and the faulting increases further.

 CPU
 util |      ____
      |    /      \
      |   /        \____ thrashing
      |__/_________________
              degree of multiprogramming

Prevention/control:

  • Working-set model: give each process enough frames for its working set; suspend a process if total demand exceeds memory.
  • Page-fault frequency (PFF): add frames if the fault rate is above an upper limit, remove if below a lower limit.
  • Use local replacement and reduce the degree of multiprogramming.

✓ Answer checked by Claude Opus 5.5 (high effort)

All Operating System chapter 4 questions →