Demonstration and Analysis of Thrashing
Demonstration and Analysis of Thrashing
1. Aim
To simulate and demonstrate Thrashing by analyzing page fault rates when the number of available frames is insufficient.
2. Objective
-
To understand the concept of Thrashing
-
To simulate page replacement under low memory conditions
-
To observe high page fault rate
-
To analyze the effect of increasing frames
3. Theory
🔹 What is Thrashing?
Thrashing occurs when:
The system spends more time handling page faults than executing actual instructions.
This happens when:
-
Number of frames is too small
-
Processes do not get enough memory
-
Page fault rate becomes extremely high
🔹 Why Does Thrashing Occur?
When frames < working set size:
-
Pages are continuously replaced
-
CPU utilization decreases
-
Disk I/O increases
-
System performance drops
🔹 Working Set Concept
Working Set = Set of pages actively used by a process.
If allocated frames < working set size → Thrashing occurs.
4. Experimental Idea
We will:
-
Use a reference string with strong locality.
-
Run FIFO with:
-
2 Frames (very low memory)
-
3 Frames
-
4 Frames
-
-
Compare page fault rates.
-
Observe that small frame size causes very high faults → Thrashing behavior.
5. Algorithm
For each frame size:
-
Initialize frames.
-
Apply FIFO page replacement.
-
Count hits and misses.
-
Calculate:
-
Page Fault Rate = Misses / Total Pages
-
-
Compare results.
C Program (Thrashing Demonstration)
Sample Output (Summary)
With 2 Frames
-
Very high page faults
-
Page Fault Rate ≈ 90%
With 3 Frames
-
Moderate page faults
-
Page Fault Rate decreases
With 4 Frames
-
Further reduced faults
6. Observation Table
| Frames | Page Fault Rate | Observation |
|---|---|---|
| 2 | Very High | Thrashing-like behavior |
| 3 | Moderate | Improved |
| 4 | Lower | Stable |
7. Analysis
When frames are very small:
-
Pages are continuously replaced
-
Fault rate increases drastically
-
CPU spends more time handling faults
-
System behaves like thrashing condition
Increasing frames reduces page faults and improves performance.
8. Result
Thrashing was successfully demonstrated. It was observed that when the number of frames is too small, page fault rate increases significantly, simulating thrashing behavior.
Comments
Post a Comment