Swapping, Swap in, Swap out in Operating Systems (OS)

Swapping, Swap in, Swap out in Operating Systems (OS)

In this tutorial, we will learn about the followings;

What is Swapping? What is Swap in? What is Swap out in Operating Systems (OS)?

 

As we know that hard disk is very cheap in price as compared to RAM (main memory), so it is economical for us to buy a big hard disk with a data storage capacity of GB’s and TB’s. But we need to know that purpose of RAM and Hard disk is a little bit different. RAM stores temporary data and hard disk stores permanent data. It means that what the RAM can do, Hard disk can’  always do. What the Hard disk can do, RAM can’t always do.

 

Further today we are living in the age of multiprogramming and multi-processing, and we have very strong CPU, so we know to program our Operating system in such a way that OS can manage multiple programs running at the same time. But when we try to execute multiple programs on CPU with a little RAM, then OS needs a mechanism for swapping the processes. Now let’s see that what is swapping.

What is Swapping?

When our main memory(RAM) is not enough to temporarily store multiple programs then we take some program from RAM and store them into the hard disk by a mechanism called swap out. Similarly when RAM is free, then we again swap in the programs from hard disk to RAM.

swapping, swap in , swap out, os operating systems
Figure: swapping, swap in, swap out

What is Swap out and swap in?

Swap out means to take the program from RAM and to bring them in Hard disk. Swap in means to take the program from Hard disk and again bring them to the RAM.

What are advantages of swapping?

  • With the help of swapping we can manage many processes within the same RAM.
  • Swapping helps to create the virtual memory.
  • Swapping is economical.