Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Allocation of Frames & Thrashing

Lesson 22 of 31 in the free Operating System & Linux Programming notes on Siksha Sarovar, written by Rohit Jangra.

How Many Frames per Process?

Each process needs a minimum number of frames so its instruction can complete after a fault. The OS chooses among:

  • Equal allocation — same frames per process.
  • Proportional allocation — frames proportional to process size or priority.

Global vs Local Replacement

  • Local replacement — process replaces among its own frames.
  • Global replacement — process can take any frame in the system. Higher throughput on average; but a misbehaving process can hog memory.

What is Thrashing?

A process is thrashing when it spends more time paging than executing. It happens when the working set does not fit in the allocated frames — every reference is a fault.

CPU utilization shows a characteristic curve: rises with multiprogramming up to a knee, then collapses as thrashing sets in.

Causes

  • Too many processes for available RAM.
  • A long-running process whose working set keeps shifting.
  • Bad replacement decisions (FIFO, MFU under wrong workload).

Combating Thrashing

  1. Working-Set Model (Denning) — for each process, the set of pages referenced in the last Δ time units. Sum of working-set sizes ≤ total frames; if not, suspend a process.
  2. Page-Fault Frequency (PFF) — keep each process's fault rate within acceptable bounds. If a process's PFF is too high, give it more frames; if too low, take some away.
  3. Reduce multiprogramming level — swap out an entire process.
  4. Add RAM — the brute-force solution.

Working-Set Computation Example

Reference string ... 2 6 1 5 7 7 7 7 5 1 6 2 3 4 1 2 3 4 4 4 ...

With Δ = 10, working set at time t = unique pages in last 10 references.

Other Memory Pressures

  • Heap fragmentation — long-running servers may need allocator tuning.
  • TLB churn — if the working set has too many distinct pages, even hot data suffers TLB misses.
  • NUMA effects — on multi-socket boxes, accessing remote-node memory is slower.

Summary

  • Thrashing collapses throughput and feeds itself unless the OS intervenes.
  • Working-set and PFF heuristics decide frame allocation.
  • The cure is more memory, fewer processes, or smarter replacement.