What is Swapping ?

Removing suspended or preempted processes from memory and their subsequent bringing back is called swapping. The basic idea of swapping is to treat main memory as a ‘pre-emptable’ resource. Lifting the program from the memory and placing it on the disk is called ‘Swapping out’. To bring the program again from the disk into the main memory is called ‘Swapping in’.

Normally, a blocked process is swapped out so as to create available space for a ready process. This results in improving CPU utilization
Advantages of Swapping

Swapping may also be helpful for improving processor utilization in partitioned memory environments by increasing the ratio of ready to resident processes. Swapping is usually employed in memory-management systems with Contiguous Allocation, such as fixed and variable partitioned memory . Somewhat modified forms of swapping may also be present in virtual memory systems based on Segmentation or on Paging. Swapping brings flexibility even to systems with fixed partitions.

When the scheduler decides to admit a new process for which no suitable free partition can be found, the swapper may be invoked to vacate such a partition.
swapping in operating system

The swapper is an Operating System process whose major responsibilities include:

  •      Selection of processes to swap out: Its criteria is suspended/blocked state, low priority, time spent in memory.
  •      Selection of processes to swap in: Its criteria are time spent on swapping device and priority.
  •      Allocation and management of swap space on a swapping device. Swap space can be system wide or dedicated.
  • Thus the swapper performs most of the functions of the medium-term scheduler. The swapper usually selects a victim among the suspended processes that occupy partitions large enough to satisfy the needs of the incoming process.
Although the mechanics of swapping out following the choice of a victim process is fairly simple in principle, implementation of swapping requires some specific provisions and considerations in Operating System that support it. These generally include the file system, specific Operating System services, and Relocation.

Leave a Reply

Your email address will not be published. Required fields are marked *