L-5.16: What is Thrashing | Operating System
Thrashing in Operating Systems
Understanding Thrashing
- Thrashing is a critical concept in operating systems, directly related to the degree of multi-programming, which refers to the number of processes present in RAM.
- The size of RAM is limited; bringing too many processes into RAM can lead to performance issues.
Impact on CPU Utilization
- When processes require input-output operations, they enter a blocked state, causing the CPU to become idle and reducing throughput.
- To maximize CPU utilization, more processes must be brought into RAM despite its limitations. This leads to the use of paging.
Paging Mechanism
- In paging, processes are divided into pages that can be loaded into RAM. For example, 100 processes can be split into pages for efficient management.
- By loading only one page from each process into RAM, multiple processes appear active even if not fully loaded.
Page Fault Scenario
- If the CPU requests a page not currently in RAM (e.g., page 2 of Process P1), this results in a page fault requiring service time to retrieve it from disk.
- A situation arises where multiple requested pages may not be present in RAM, leading to increased page faults and degraded performance.
Consequences of Excessive Multi-programming
- As more pages are added without sufficient availability for CPU requests, thrashing occurs—characterized by excessive page faults and reduced system efficiency.
- Graphically represented: as degree of multi-programming increases (x-axis), initially CPU utilization rises (y-axis), but eventually leads to thrashing when too many faults occur.
Solutions to Mitigate Thrashing
- To alleviate thrashing, increasing main memory size is one option; however, this isn't always feasible due to hardware constraints.
Long Term, Short Term, and Middle Term Scheduling
Responsibilities of Long Term Scheduler
- The long term scheduler is responsible for maximizing the number of processes in RAM or in a ready state.
- It aims to bring as many processes into RAM as possible without overwhelming the system.
- If the long term scheduler decreases its speed, it can help manage the degree of multiprogramming effectively.
Managing Degree of Multiprogramming
- By controlling the degree of multiprogramming, thrashing can be minimized, which is crucial for maintaining system performance.