×

Thrashing in Operating System

A virtual memory system's poor performance when the same pages are loaded repeatedly due to a lack of main memory to store them in secondary memory is referred to as "thrash" in computer science.

We all know that a program needs to be in the main memory, or RAM, to run. Although large programs, such as video games, can be easily downloaded and stored in GBs on secondary memory devices (such as hard disks or SSDs), they eventually need to be transferred to RAM when they are executed. Data can be managed between primary memory and secondary memory using a variety of memory management strategies. Paging is one of the most commonly used strategies. Because RAM is smaller than secondary memory, it cannot completely store programs that are larger than RAM's capacity. As a result, memory management is essential.

When does Thrashing occur?

In Computing, when virtual memory is used, thrashing occurs. It occurs when a computer's virtual memory rapidly swaps data on the hard disk, obstructing most application-level processing. Additional pages need to be moved into and out of virtual memory as the main memory gets full. A very high rate of hard disk access is caused by the swapping. Thrashing can last a long time until the underlying problem is fixed. The computer's hard drive could completely collapse if it is thrashed.

What is thrashing in Operating System?

The operating system needs to spend more time switching these pages if page faults and swapping occur frequently. This is referred to as thrashing in the operating system. Thrashing in the operating system will result in a reduction in CPU usage.

Thrashing in operating system is a peculiarity in processing that happens when virtual memory is utilized. It occurs when the virtual memory of a computer quickly swaps data with data on the hard drive, obstructing most application-level operations. More pages must be moved into and out of virtual memory as the main memory runs out.

As a result, disk thrashing is a term used to describe operating system thrashing.

If the CPU spends more time serving page faults than executing the pages, a process is said to be thrashing. As a result, CPU usage is reduced, and the operating system attempts to increase multiprogramming.

Causes of Thrashing

Operating system thrashing has an effect on how well the execution of the operating system works. Additionally, the operating system suffers from serious performance issues as a result of Thrashing.

The process scheduling mechanism tries to load many processes into memory when the CPU usage is low, allowing the level of multiprogramming to rise. In this instance, there are more processes in the memory than available memory frames. If the frame is not currently vacant when a high-priority process enters memory, the occupied process will be moved to secondary storage and the free frame will be assigned to a higher-priority process.

We could also argue that the process begins to take a long time to swap in the required pages as soon as the memory is full. CPU usage decreases once more as the majority of applications wait for pages.

As a result, operating system thrashing is frequently caused by a lack of frames and a high degree of multiprogramming.

We can say that thrashing occurs due to the following reasons:

  1. The process scheduling method that adds more processes when the CPU is not being used as much.
  2. Multiprogramming at a high level.
  3. Less frames than the processes that are needed.

Page Replacement Algorithms and Effect of Thrashing in OS

Using either the global frames replacement algorithm or the local frames replacement algorithm, the operating system tries to add enough pages to the main memory to deal with page faults. The Effects of these various replacement strategies on thrashing are explained below:

  • The Global Page Replacement can bring any page, and if Thrashing in the operating system is detected, it will attempt to bring additional pages. This means that no process can get enough frames, and the operating system's thrashing will get worse. In conclusion, the global page replacement strategy fails when operating system thrashing occurs.
  • Local Page Replacement, in contrast to Global Page Replacement, will select pages that are associated with that process. Consequently, there is a possibility that the operating system's thrashing will decrease.

Related Topics

Difference between Process and Program in the Operating System

What is a process in the Operating System? A process is a program that is going through the execution. It also helps us to execute all the lines of code in...

4 minutes read.

SCAN Disk Scheduling Algorithm

SCAN Disk Scheduling Algorithm The SCAN disk scheduling algorithm is another type of disk scheduling algorithm. In this algorithm, we move the disk arm into a specific direction (direction can be moved towards...

4 minutes read.

What is Deadlock in OS?

Deadlock in Operating System In an Operating System, a process uses various resources, and the resources are used in the following manner: Request the ResourceUse the ResourceRelease the Resource In the Operating System, Deadlock is a condition...

4 minutes read.

Single-User Operating System

An operating system designed and intended to be used on a computer or device with a single user at a time is known as a single-user operating system. Devices like...

8 minutes read.

Dining Philosophers Problem in Operating System

Edsger Wybe Dijkstra was a well-known Dutch scientist. He was the first person ever to present the Dining Philosophers Problem in the stream of Computer Science. The dining philosophers problem...

5 minutes read.

Simple Structure in Operating System

An operating system is a piece of software that lets the user applications talk to the hardware of the system. Because it is such a complicated structure, the operating system...

3 minutes read.

FCFS Scheduling in OS

FCFS: First Come First Serve Scheduling in OS FCFS is a non-preemptive and preemptive scheduling algorithm that is easy to understand and use. In this, the process which reaches first is...

3 minutes read.

Inter Process Communication in Operating System

Inter-Process Communication or IPC refers to the methods and techniques that allow processes (programs or tasks) to communicate with each other within a computer system. This is typically done through...

3 minutes read.

Difference between Seek Time and Disk Access Time in Disk Scheduling

Seek Time The time taken for the hard disk controller to detect a specific piece of recorded data is known as the seek time. The amount of time it takes to...

4 minutes read.

What is Scheduling on OS

Scheduling is the process which is used to share the computing resources such as memory, processor time, and bandwidth to the different processes, data flows, threads, and applications which need them. Scheduling is...

5 minutes read.

Distributed Shared Memory

Distributed Shared Memory is a process of managing memory over more than one node and makes inter-process communication which transfers to end users. It is a mechanism that allows user...

2 minutes read.

Difference between Rotational Latency and Disk Assess Time in Disk Scheduling

Disk scheduling is used by operating systems to arrange the arrival of I/O requests to the disc. Disk scheduling is necessary because several I/O requests may occur from various processes,...

4 minutes read.

Look Disk Scheduling

Look Disk Scheduling Look disk scheduling is another type of disk scheduling algorithm. Look scheduling is an enhanced version of SCAN disk scheduling. Look disk scheduling is the same as SCAN disk scheduling,...

4 minutes read.

What is Demand Paging?

Demand Paging is defined as a process in which the pages are loaded into the memory (when the page fault occurs) or on-demand. It consists of the following steps: If there is...

4 minutes read.

Scheduling Algorithms in OS

There are various types of scheduling algorithm which are used by the operating system to schedule the process on the processor. Objective of Scheduling Algorithms There are the following objectives of Scheduling Algorithms: Fare allocation...

2 minutes read.

Interested Variable Mechanism

Interested Variable Mechanism It is a must to provide progress to the process synchronization mechanism. In variable mechanism, if there is a process that doesn’t need to enter into the critical section, then due...

5 minutes read.

Lock Variable Mechanism | Operating System

Lock Variable Mechanism The Lock variable mechanism is a synchronization mechanism that is implemented in a user mode. It is a software procedure. Lock variable is a solution for busy waiting that can be...

3 minutes read.

How to implement Monitors using Semaphores

Monitors Monitor is a type of synchronization device designed to solve difficulties caused by semaphores, such as timing errors. Monitors are the type of data types that are abstract by nature...

2 minutes read.

Trap vs Interrupt in Operating System

What is Trap in Operating System? A trap is a synchronous interrupt used to perform functionality when an error occurs in a user process. A trap in an operating system can...

4 minutes read.

Functions of Operating System

The functions of Operating System are: Process Management Memory Management File Management Device Management Secondary storage Management Security Coordination between other software and users Networking Job Accounting Error detecting aids 1. Process Management Process Management support operating system to create and delete...

3 minutes read.