
- OS - Home
- OS - Needs
- OS - Overview
- OS - History
- OS - Components
- OS - Structure
- OS - Architecture
- OS - Services
- OS - Properties
- OS - TAT & WAT
- OS Processes
- OS - Processes
- OS - Process Scheduling
- OS - Scheduling Algorithms
- FCFS Scheduling Algorithm
- SJF Scheduling Algorithm
- Round Robin Scheduling Algorithms
- HRRN Scheduling Algorithms
- Priority Scheduling Algorithms
- Multilevel Queue Scheduling
- Context Switching
- Operations on Processes
- Lottery Process Scheduling
- Predicting Burst Time SJF Scheduling
- Race Condition Vulnerability
- Critical Section Synchronization
- Mutual Exclusion Synchronization
- Process Control Block
- Inter Process Communication
- Preemptive and Non-Preemptive Scheduling
- Operating System - Deadlock
- Introduction to Deadlock in Operating System
- Conditions for Deadlock in Operating System
- OS Synchronization
- Operating System - Process Synchronization
- Operating System - Critical Section
- Operating System - Semaphores
- Operating System - Counting Semaphores
- Operating System - Mutex
- Operating System - Lock Variable in Process Synchronization
- Operating System - Turn Variable in Process Synchronization
- Operating System - Bounded Buffer Problem
- Operating System - Reader Writer Locks in Process Synchronization
- Operating System - Test Set Lock in Process Synchronization
- Operating System - Peterson Solution in Process Synchronization
- Operating System - Monitors in Process Synchronization
- Operating System - Sleep and Wake in Process Synchronization
- OS Memory Management
- OS - Memory Management
- OS - Virtual Memory
- OS Storage Management
- File Systems in Operating System
- Linked Index Allocation in Operating System
- Indexed Allocation in Operating System
- Structures of Directory in Operating System
- File Attributes in Operating System
- Operating System - Page Replacement
- Operating Systems - Thrashing
- Belady’s Anomaly in Page Replacement Algorithms
- Optimal Page Replacement Algorithm
- Operating System - Types
- Types of Operating System
- Batch Processing Operating System
- Multiprocessing Operating System
- Hybrid Operating System
- Monolithic Operating System
- Zephyr Operating System
- Nix Operating System
- Blackberry Operating System
- Garuda Operating System
- Tails Operating System
- Clustered Operating System
- Haiku Operating System
- AIX Operating System
- Solus Operating system
- Tizen Operating System
- Bharat Operating System
- Fire Operating System
- Bliss Operating System
- VxWorks Operating System
- Embedded Operating System
- Single User Operating System
- OS Miscellaneous
- OS - Multi-threading
- OS - I/O Hardware
- OS - I/O Software
- OS - Security
- OS - Linux
- OS Useful Resources
- OS - Quick Guide
- OS - Useful Resources
- OS - Discussion
Operating Systems - Thrashing
Thrashing in an operating system refers to a situation where the system spends the majority of its time swapping data between RAM and secondary storage (usually the disk), instead of executing actual processes. This occurs when there is excessive pagingthe operating system is forced to constantly swap pages in and out of memory, leading to a severe degradation in system performance.
Cause of Threasing
Threasing occurs due to the following reasons:
Insufficient Physical Memory: When the system doesnt have enough RAM to hold the pages of all running processes, the operating system has to swap pages in and out of physical memory constantly to make room for new pages.
Too Many Processes: Running too many processes simultaneously or processes with large memory requirements can cause the system to exceed its physical memory capacity. When there is not enough memory for all processes, the system has to swap pages frequently.
High Degree of Multiprogramming: In some cases, a system may try to run too many programs or processes at once, each requiring more memory than the system can provide. As a result, the operating system is forced to perform excessive paging, leading to thrashing.
Poor Page Replacement Algorithms: Inefficient page replacement algorithms (e.g., FIFO) can exacerbate thrashing by swapping pages that will soon be needed again, increasing the number of page faults.
Effects of Threasing
Following are the effects of threasing:
Severe Performance Degradation: The CPU spends more time managing memory (swapping pages) than executing processes, which results in a significant slowdown of the system.
Increased Disk I/O: The frequent swapping of pages between RAM and the disk leads to excessive disk input/output, which is much slower than accessing memory, further contributing to the performance drop.
Reduced CPU Utilization: The CPU becomes underutilized because most of its time is spent waiting for page swaps instead of executing process instructions.
How to prevent threasing?
Using the following ways we can prevent thresing:
Reducing Multiprogramming: By reducing the number of processes running simultaneously, the system can ensure that each process has enough memory to avoid excessive paging.
Proper Memory Allocation: Allocating enough physical memory to ensure that the working sets of processes fit into memory is crucial in preventing thrashing.
Using Better Page Replacement Algorithms: More efficient algorithms, such as Least Recently Used (LRU) or Optimal Page Replacement, can help reduce the frequency of page faults and prevent thrashing by better managing the pages in memory.
Adjusting the Degree of Multiprogramming: The operating system can control the number of processes running based on the available physical memory. This can help prevent memory overload.
Using Virtual Memory Properly: Effective use of virtual memory ensures that the system can handle more data than what fits in physical RAM, but care must be taken to avoid overwhelming the disk I/O with too many page swaps.
Working Set Model: The operating system can use a working set model to determine how much memory each process needs at any given time and make sure that the required pages for each process are kept in memory.