Thrashing
Thrashing occurs in a computer system when the operating system spends a significant amount of time swapping pages in and out of memory, rather than executing actual processes. This typically happens when the system's memory is overcommitted, meaning there are too many processes competing for too little physical memory, leading to frequent page faults. How Memory is Used
1. Initial State: App1 is running, and its two pages are loaded into memory:
- Frame 1: App1, Page 1
- Frame 2: App1, Page 2
- Frame 3 and 4 are free.
- App3's pages are present in swap memory.
2. Switch to App2: Now, you switch to App2, which also requires 2 pages:
- Frame 3: App2, Page 1
- Frame 4: App2, Page 2
- Memory is now full with both App1 and App2’s pages.
- App3's pages are present in swap memory.
3. Switch to App3:
- You decide to switch to App3, which needs 2 pages as well.
- Since the memory is full, the system needs to make room:
- App1’s pages are moved to swap memory:
- Swap Memory: [App1, Page 1] [App1, Page 2]
- Frame 1: App3, Page 1 (replaces App1’s Page 1)
- Frame 2: App3, Page 2 (replaces App1’s Page 2)
- App2’s pages remain in RAM, and App1’s pages are stored in swap memory.
4. Switch Back to App1:
- When you return to App1, the system needs to reload its pages.
- App3’s pages are moved to swap memory.
- Swap Memory: [App3, Page 1] [App3, Page 2]
- Frame 1: App1, Page 1 (replaces App3’s Page 1)
- Frame 2: App1, Page 2 (replaces App3’s Page 2)
In this scenario, each time the user switches between App1 and App3, the system has to swap one application out of RAM and load the other one in from swap memory. This constant swapping means:
- Excessive Disk I/O: The system spends a lot of time reading from and writing to the disk.
- High Latency: The user experiences significant delays each time they switch between applications.
- Poor Performance: The CPU is mostly occupied with handling page faults and managing swap operations rather than executing the actual tasks of the applications.

Comments
Post a Comment