Q1. What is Swapping?

Ans. The program that is ready for execution must be brought into main memory for execution, and then the passive program become active for execution and it is termed as process. We have already discussed in CPU scheduling that there must be always some process residing in main memory for execution, to improve the performance of the processor (CPU). Moreover the execution of the process can be interrupted and scheduled later if a process with higher priority is encountered, since there is not enough main memory to hold all currently active processes. Then the later process must be brought into main memory from the disk (secondary storage) and the former process may be taken back into disk so that to accommodate the later process. This procedure of moving the process to the main memory from disk and to the disk from the main memory is called as swapping.



Figure: Swapping of two processes using a disk as a backing store.

When the process is moved from the main memory to the disk, the procedure is swap-out whereas, when the program is brought into main memory from the disk, then the procedure is called as swap-in.

Swapping becomes almost compulsory in case of multiuser or multiprogramming environment. The swapping of process to increases the overall turnaround time. The swapping time is directly proportional to size of memory swapped. Actually it is the transfer time. The idle process residing in memory must be selected for swapping.

Leave a Reply

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