Swapping in Operating System (OS)
What is Swapping in OS
Swapping is a simple memory or process management method used by the operating system (O.S). This method is dedicated to increasing the utilization of the processor by moving blocks of data in and out of the main memory. This data and information are swapped between the main and the secondary memory to optimize memory utilization and increase the processing power.
The process of swapping also forms a queue of temporarily suspended processes as the execution carries out with the newly arrived process. The concept of swapping consists of two more concepts, swap in and swap out.
Swap Out is the method of removing a process from the RAM and adding it to the Hard Disk. On the other hand, swap in means, removing the program from the hard disk and placing it back into the main memory or the RAM.
Learn about difference between segmentation and paging here.
Advantages of Swapping
- The process helps the CPU to manage multiple processes within the same main memory.
- The method helps to create and use Virtual Memory.
- The method is economical.
- Swapping makes a CPU perform several tasks simultaneously. Hence, processes do not have to wait for too long before they are executed.
Disadvantages of Swapping
Although the process has no significant or effective disadvantage, the overall method depends heavily on the virtual memory. Such dependability results in a significant performance drop.
- In the case of heavy swapping activity, if the computer system loses power, the user might lose all the information related to the program.
- If the swapping algorithm is not good, the overall method can increase the number of page faults and decline the overall processing performance.
- Inefficiency may arise in the case where a resources or a variable is commonly used by the processes which are participating in the swapping process.
Operating System which uses Swapping
- UNIX systems use a swapping mechanism if the main memory gets The system may discontinue swapping when the load on the processor drops.
- Windows 3.1 is another operating system which uses swapping when the load on the processor is heavy.
Mobile Systems using Swapping
Mobile phone usually does not use the concept of swapping during their operation. The most popular mechanism used by them is flash memory which is more efficient than the hard drives used for persistent storage. The flash memory can only be written a limited number of times before it becomes unreliable. Thus, the method is avoided to be used in the case of mobile devices.
- Memory Management Introduction
- Partition Allocation Method
- Buddy- System Allocator
- Types of Paging
- Mapping Virtual address to Physical Address.
- Virtual Memory
- Demand Paging
- Implementation of Demand paging and page fault
- Page Replacement Algorithms
- Belady’s Anomaly
- Static vs Dynamic Loading
- Static vs Dynamic Linking
- Translational Look Aside Buffer
- Process Address Space
- Difference between Segmentation and Paging