0
0
Operating Systemsknowledge~10 mins

Thrashing and working set model in Operating Systems - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Thrashing and working set model
Process starts running
Needs pages in memory
Check if enough frames
Load pages
Process runs
Working set tracked
Adjust frames based on working set
Process runs smoothly
This flow shows how a process requests memory pages, how lack of frames causes thrashing, and how the working set model helps manage frames to avoid thrashing.
Execution Sample
Operating Systems
Process requests pages
If frames < working set size
  Page faults increase
  Thrashing occurs
OS tracks working set
OS adjusts frames
Process runs smoothly
This pseudo-code shows how the system checks if the process has enough memory frames to hold its working set and adjusts to prevent thrashing.
Analysis Table
StepConditionActionResult
1Process starts runningRequest pagesPages needed in memory
2Frames available >= working set size?YesLoad pages into frames
3Process runsAccess pagesFew page faults
4Frames available < working set size?YesPage faults increase
5Page faults highThrashing occursProcess slows down
6OS tracks working setCalculate pages used recentlyWorking set size determined
7OS adjusts framesAllocate frames to match working setPage faults reduce
8Process runsAccess pagesRuns smoothly again
💡 Thrashing stops when OS allocates enough frames to cover the working set size.
State Tracker
VariableStartAfter Step 3After Step 5After Step 7Final
Frames availableEnoughEnoughInsufficientAdjustedEnough
Page faults0LowHighReducedLow
Working set sizeUnknownUnknownTrackedDeterminedStable
Key Insights - 3 Insights
Why does thrashing cause the process to slow down?
Because the process keeps causing page faults and waiting for pages to load, it spends more time swapping pages than doing useful work (see execution_table step 5).
How does the working set model help prevent thrashing?
It tracks the pages the process uses recently and ensures enough frames are allocated to hold these pages, reducing page faults (see execution_table steps 6 and 7).
What happens if the OS does not adjust frames based on the working set?
The process will continue to thrash because it does not have enough frames to hold its needed pages, causing high page faults and slow execution (see execution_table steps 4 and 5).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at which step does thrashing start?
AStep 5
BStep 4
CStep 3
DStep 6
💡 Hint
Check the 'Action' and 'Result' columns where 'Thrashing occurs' is mentioned.
According to variable_tracker, what happens to page faults after OS adjusts frames?
APage faults increase
BPage faults stay high
CPage faults reduce
DPage faults become zero
💡 Hint
Look at the 'Page faults' row after Step 7 in variable_tracker.
If the working set size is underestimated, what is likely to happen?
AProcess will run smoothly
BThrashing will continue
CFrames will be over-allocated
DPage faults will be zero
💡 Hint
Refer to key_moments about the importance of matching frames to working set size.
Concept Snapshot
Thrashing happens when a process has too few memory frames, causing many page faults and slow execution.
The working set model tracks the pages a process uses recently.
OS allocates frames to cover the working set to reduce thrashing.
Adjusting frames based on working set size helps the process run smoothly.
Full Transcript
Thrashing occurs when a process does not have enough memory frames to hold the pages it needs, causing frequent page faults and slowing down the process. The working set model helps by tracking the pages the process uses recently and ensuring enough frames are allocated to hold these pages. When the OS detects thrashing, it calculates the working set size and adjusts the number of frames allocated to the process. This reduces page faults and allows the process to run smoothly again.