What is thrashing in OS

 


Introduction

Thrashing’ is a term which may sound familiar to you, isn’t it? Remember the days when our moms used to thrash the shit out of us? Don’t worry, this thrashing has got nothing to do with our horror yet funny past experiences. In this article, we will be learning about Thrashing in Operating systems and some techniques to resolve that, as no one wants to get trashed all the time!

When the Operating system is busy handling page faults and swapping the pages so often, the CPU loses its efficiency. Handling page faults is an expensive process in terms of time, resulting in a decrease in CPU utilisation. This state is known as thrashing in Operating System. Let us understand this briefly in the next section.

What is Thrashing in Operating systems?


Our main objective is to maximise the CPU utilisation in a computer system, and the best way to do this is to prevent the CPU from remaining Idle. For this, we need many processes to be in the ready queue for a long period of time.

Suppose there are only three-four processes in the RAM or the ready queue, and all of them require some type of Input-Output operation. Then, for that time, the ready queue will get empty, which will make the CPU idle and hence it will decrease the CPU utilisation.

You must be wondering why don’t we add all the processes in the RAM at once to keep the CPU busy. It cannot be done as we know that the RAM has very limited memory, and hence it cannot contain every process at once. Now, in this situation, we need a messiah and here comes the concept of paging into the role.

Paging is a process in which we divide every process into multiple pages or fractions, and we keep a record of these pages in a page table. Since the memory inside the RAM is limited, we only store some pages of every process in the RAM at once, and this ensures that the CPU is kept busy. But again, there arises a problem, what if the CPU wants to execute that page or that fraction of the process which is not present in the main memory or the RAM. The RAM will now find the desired page inside the hard disk, and since the RAM is full of pages of different processes, it will swap the desired page with some random page. This leads to a wastage of time as this process is very expensive, and this fault is known as a page fault.

Comments

Popular posts from this blog

Mock Test For Various Companies

What is the process of TCS's next step?

How Mock Tests Will Help You To Ace The Entrance Examinations?