What is thrashing?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Operating Systems basics — a prerequisite for any developer role.
Answer
Thrashing is a condition where a system spends more time swapping pages in and out of memory than executing actual process instructions — the CPU is mostly waiting for disk I/O, and throughput collapses. How thrashing occurs: as the OS adds more processes to increase CPU utilization → each process gets fewer frames → more page faults → processes spend more time waiting for pages → CPU becomes idle → OS adds even more processes → even more page faults → positive feedback loop → thrashing! Symptoms: CPU utilization drops to near 0%; paging device (disk/SSD) is 100% busy; system appears to freeze or be extremely slow; all processes are waiting; adding more processes makes it worse. Detection: monitor page fault rate. If rate suddenly spikes, thrashing may be occurring. Solutions: (1) Working set model: identify each process's "working set" (pages actively used) and ensure it has enough frames. If frames available < sum of all working sets, suspend a process; (2) Page fault frequency control: if PFF rate too high → give process more frames; if rate too low → take frames away. Suspend a process if no more frames available; (3) Reduce degree of multiprogramming: suspend and swap out some processes to give remaining ones enough frames; (4) Add more physical RAM: most effective long-term solution. Working set: W(t, Δ) = set of pages referenced in the last Δ time units. OS tracks this and allocates frames accordingly. If process doesn't have all its working set in memory → thrashing for that process.
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last Operating Systems project, I used this when...' immediately makes your answer more credible and memorable.
Previous
What is a system call?
Next
What is the difference between preemptive and non-preemptive scheduling?