Swapping in OS

OS uses a technique for efficient usage of memory management in computer system, called Swapping. Swapping has two basic tasks. One is swapping-IN and other is swapping-OUT.

Swapping-IN: The Placing of blocks or pages from the hard disk to the main memory is swapping-IN.

Swapping-OUT: The Removing of blocks or pages from the main memory to the hard disk is swapping-Out.

Swapping technique is useful when need to execute the larger file. It may be even bigger than size of the main memory.

Swapping in OS with example

Let suppose there are four Processes P1, P2, P3 and P4 In secondary memory. Swapping IN and OUT is fully explain through diagram is in the below diagram.

swapping example

Advantage

  1. We can experience different environments by Swapping without having to exchange the hardware’s.

Disadvantages

  1. In swapping multiple holes are created into the memory. To remove these holes compaction is used. Compaction requires a lot of CPU time. That’s why this technique is not a good choice.
  2. The current hardware may or may not support to run other OS. Due to which more errors can occur or startup of system takes too much time.