Published by: Zaya
Published date: 22 Jun 2021
• 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.
Here, are major benefits/pros of swapping:
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