Skip to content

Memory Management

Operating Systems
└── Memory Management
└── Virtual Memory
├── Paging
├── Demand Paging
├── Page Replacement
├── Thrashing
└── Working Set Model

Programs do not access all memory randomly.

They usually access:

  • the same data repeatedly (Temporal Locality) ⭐
  • nearby memory locations (Spatial Locality) ⭐

This behavior is called the Principle of Locality.

The working set is: The set of pages currently being actively used by a process during a time interval.

Notation:

W(t,Δ)W(t, \Delta) Where:

  • tt = current time
  • Δ\Delta = working set window

It contains all pages referenced in the last Δ\Delta time units.

The OS keeps the working set pages in memory to:

  • reduce page faults
  • improve performance
  • prevent thrashing

Thrashing occurs when:

  • too many page faults happen
  • CPU spends more time swapping pages than executing processes

Cause:

  • insufficient frames allocated to processes
5. Relation Between Working Set and Thrashing
Section titled “5. Relation Between Working Set and Thrashing”
  • If all working set pages fit in RAM → system works efficiently
  • If working sets do not fit → thrashing occurs

Thus:

Working Set Model is used to control/prevent thrashing.

ConceptRelated To
Working Set ModelPrinciple of Locality
ThrashingExcessive Paging
PagingVirtual Memory
SegmentationMemory division by logical units
  • Working set model is based on locality of reference.
  • Working set helps prevent thrashing.
  • Thrashing increases page faults and reduces CPU utilization.
  • Working set is used in virtual memory management.