×

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

Advantages of UNIX Operating System

What is UNIX OS? UNIX is a family of multitasking, multiuser operating systems that are used on a wide variety of computer platforms. It was developed in the late 1960s and...

4 minutes read.

Components of Operating System

Components of Operating System: An operating system is a complex and vast system. We can only create the operating system by dividing it into small parts. Each part must be...

5 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.

Difference between SCAN and FCFS Disk Scheduling Algorithm

SCAN / Elevator Algorithm A different form of disc scheduling method is the SCAN disc scheduling algorithm. We move the disc arm in a certain direction in this process (the direction...

3 minutes read.

Booting Process in Operating System

What is Booting? Booting is defined as the term which says that the process of loading the operating system into the memory. The process of booting begins when we switch on...

4 minutes read.

What is Thread and Types of Thread

What is Thread A thread means a lightweight process. Thread is the basic unit of CPU execution, which consists of thread ID, Program counter, set of registers to hold the information of current...

7 minutes read.

N-Step-SCAN Disk Scheduling

Before you study about N-Step-SCAN Disk Scheduling, it requires prerequisite of what is Disk Scheduling Algorithms: Operating systems use disc scheduling to schedule I/O requests that arrive at the disc....

4 minutes read.

Unix Operating System

Unix Operating System Unix Operating System is a multiuser, portable, time-sharing, and multitasking operating system that was developed in 1969. Unix operating system was developed by a group of AT &...

3 minutes read.

Test Set Lock Mechanism | Operating System

Modification in the Assembly Code The problem in the lock variable is that, in some cases, the process reads the previous or old value of the lock variable and enters into the critical...

4 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.

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.

Producer-Consumer Problem in OS

What is Producer-Consumer Problem? The Producer-Consumer problem is a classical problem. The Producer-Consumer problem is used for multi-process synchronization, which means synchronization between more than one processes. In this problem, we have one producer...

4 minutes read.

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...

3 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.

Deadlock Detection and Recovery

Deadlock Detection and Recovery In deadlock detection and recovery, to avoid or prevent a deadlock, the operating system uses various methods. For checking deadlock, an operating system continuously monitors the system. Then also,...

2 minutes read.

Two Phase Locking Protocol

What is two phase locking? Two-phase locking is a concurrency control method in a database and transaction processing system. It ensures that transactions are executed in a serializable manner by requiring...

4 minutes read.

Difference between C-SCAN and SSTF Disk Scheduling Algorithm

C-SCAN / Circular Elevator The circular SCAN (C-SCAN) scheduling method is a modified version of the SCAN disc scheduling technique that addresses the SCAN algorithm's inefficiency by more equitably serving requests....

3 minutes read.

Kernel in OS

What is Kernel in OS? The kernel is the core component in the operating system. The job of the kernel is to handle the communication between the hardware and the software. ...

2 minutes read.

Advantages of Operating System

What is an Operating System?   An operating system is an interface that helps to communicate with the user and the computer hardware. Operating systems are used for file management, memory...

3 minutes read.

MS-DOS Operating System

It is also referred to occasionally as "DOS", an abbreviation for disc operating systems. Operating systems with a graphical user interface (GUI) in different iterations of the graphical Microsoft Windows...

5 minutes read.