Keeping all processes in memory all the time requires a large amount of main memory. For execution of the process, it must be swapped.
Swapping
• Keeping all processes in memory all the time requires a large
amount of main memory. For execution of the process, it must be swapped.
•
Swapping is method of temporarily
removing inactive process/programs from the physical memory.
•
Inactive program means, which is neither executing on the CPU, nor performing
an I/O operation.
• Fig. 4.2.1 shows swapping
• When process P2 send
requests for an I/O operation, OS blocked P2 process and will not
return to the ready state for long period of time. Process P2 is in
blocked state. Process manager place the process P2 in blocked state
and inform to the memory manager regarding this action.
• Process manager moves a blocked
process P1 into the ready state and inform to memory manager.
Process P1 is loaded into main memory by memory manager when there
is space available.
• Swapped out process is stored on the
secondary storage disk. It contains executable image with code, data and stack.
• Relocation hardware supports for
swapping. Because of address binding problem, swapping is difficult without
relocation hardware.
• Round robin and priority based CPU scheduling algorithm uses
the swapping concept.
•
Time sharing system uses swapping. In time sharing, kernel can estimate when a
program is likely to be scheduled next.
• A swapped out process will occupy same
memory location when process swap in by OS. But this totally depends on address
binding. If address binding is load time or assembly time, then swapped out
process uses same memory location when swap-in. But execution-time binding uses
different memory location.
• Secondary storage is required to
implement the swapping technique.
•
Content switching time increases when swapping increases. Major part of the
swap time is transfer time. Swapping increases the operating system overhead
due to the disk I/O involved.
• When
swapping creates multiple holes in memory, it is possible to combine them all
into one by moving all the processes to one side of memory. This technique is
known as memory compaction.
• Compaction requires a lot of CPU time,
so most operating systems not used this technique.
Introduction to Operating Systems: Unit III: Memory Management : Tag: : Memory Management - Introduction to Operating Systems - Swapping
Introduction to Operating Systems
CS3451 4th Semester CSE Dept | 2021 Regulation | 4th Semester CSE Dept 2021 Regulation