Concept of Swapping

Filter Course


Concept of Swapping

Published by: Zaya

Published date: 22 Jun 2021

Concept of Swapping Photo

Concept of Swapping

• Swapping is a mechanism in which a process can be swapped temporarily out of the main memory (or move) to secondary storage (disk) and make that memory available to other processes.
• Backing store is usually a hard disk drive or any other secondary storage which fast in access and large enough to accommodate copies of all memory images for all users. It must be capable of providing direct access to these memory images
• At some later time, the system swaps back the process from the secondary storage to the main memory.
• Similar to round-robin CPU-scheduling algorithm, when a quantum expires, the memory manager will swap out that process to swap another process into the memory space that has been freed
• The total time taken by the swapping process includes the time it takes to move the entire process to a secondary disk and then to copy the process back to memory, as well as the time the process takes to regain main memory.

swapping

swapping 1

Benefits of Swapping

Here, are major benefits/pros of swapping:

  • It offers a higher degree of multi-programming.
  • Allows dynamic relocation. For example, if address binding at execution time is being used, then processes can be swap in different locations. Else in the case of compile and load time bindings, processes should be moved to the same location.
  • It helps to get better utilization of memory.
  • Minimum wastage of CPU time on completion so it can easily be applied to a priority-based scheduling method to improve its performance.

Relocation and protection

Relocation
• Programmers typically do not know in advance which other programs will be resident in main memory at the time of execution of their Program
• Active processes need to be able to be swapped in and out of main memory in order to maximize processor utilization
• Specifying that a process must be placed in the same memory region when it is swapped back in would be limiting
 may need to relocate the process to a different area of memory

Protection
• Processes need to acquire permission to reference memory locations for reading or writing purposes
• Location of a program in main memory is unpredictable
• Memory references generated by a process must be checked at run time
• Mechanisms that support relocation also support the protection