For improving the performance of the system we use the concept of swapping. Swapping is a simple memory/process management technique used by the operating system (os) to increase the utilization of the processor by moving some blocked process from the main memory to the secondary memory (hard disk).
It is a technique in which the processes those are on waiting state and those are on suspend or temporary suspend will be stored from outside the memory locations so that the speed of process will be high.In this the process those are waiting for some input and output are transferred to the physical memory from they are running and the processes those are ready for the execution will be execute by the cpu.
When there is a situation to perform swapping, then we uses the sweeper. The sweeper is used for
1) Selecting which process to be out
2) Selecting which process to be in
3) Providing the memory space to the processes those are newly entered.
In this sweeper will select the suspended process then brings the ready process in memory and after the execution that suspended process will be again entered into the memory by the sweeper.
For swapping the sweeper also uses some address those are also known as the logical and physical address of processes. For providing the logical address into the physical address there the following two approaches used.
1) Static relocation. : In the static relocation swapping never to be performed because the process are always have a memory. Which is not to be changed at the execution time. For example the memory which is provided to the input and output operations and the memory which is provided to the cpu for executing the processes will not be changed so that this is also known as the static relocation of the memory.
2) Dynamic relocation. The dynamic relocation is also known as the memory which is changed and relocates by the processes at the time of execution. So that there must be some mechanism to provide memory those processes those are running. The mapping of the logical address into the physical address will be performed at the time of execution or at run time.
When the memory is provided to the process then the particular address is stored by the cpu which is also have a entry into the partition description table means in which partitions a process is running because when the process needs swapping that particular address must be reloaded.
The Purpose Of Swapping
The purpose of swapping, or paging, is to access data being stored in hard disk and to bring it into the RAM so that it can be used by the application program. Remember that swapping is only necessary when that data is not already in the RAM.