/    /  OS – Swapping in Operating System

Swapping in Operating System

 

Swapping is a memory management scheme in which the processes are temporarily switched from the main memory to the secondary memory. It is done so that the main memory can be made available for other processes.

The place where the swapped-out memories are kept is called swap space. 

 

Swapping is used when the data is not present in the RAM. It is helpful to run larger and multiple processes. Therefore it is also known as memory compaction. 

 

It is further divided into two types:

  1. Swap-in: Swap-in is the method of removing a program from the hard disk and putting it back in the RAM. 
  2. Swap-out: Swap-out removes a program from the RAM and puts it into the hard disk.

 

Advantages of Swapping:

The advantages of swapping are as follows:

  1. Helps the CPU manage multiple processes at the same time.
  2. Helps create and use virtual memory.
  3. Helps improve the main memory utilization.
  4. Processes do not have to wait very long to be executed.

 

Disadvantages of Swapping:

The disadvantages of swapping are as follows:

  1. There are chances of losing information if the computer system loses power supply.
  2. In a case where the swapping method is not suitable, the composite method can increase the number of page faults. Hence, decrease overall performance.

 

Reference

Swapping in Operating System