Compare the Difference Between Similar Terms

Difference Between Paging and Swapping

Paging vs Swapping

Paging is a memory management method used by operating systems. Paging allows the main memory to use data that is residing on a secondary storage device. These data are stored in the secondary storage device as blocks of equal size called pages. Paging allows the operating system to use data that will not fit in to the main memory. Swapping is a term that is used to describe the act of moving all the segments belonging to a process between the main memory and a secondary storage device.

What is Paging?

Paging is a memory management method used by operating systems. Paging allows the main memory to use data that is residing on a secondary storage device. These data are stored in the secondary storage device as blocks of same size called pages. Paging allows the operating system to use data that will not fit in to the main memory. When a program tries to access a page, first the page table is checked to see whether that page is on the main memory. Page table holds details about where the pages are stored. If it is not in the main memory, it is called a page fault. Operating system is responsible for handling page faults without showing it to the program. The operating system first finds where that particular page is stored in the secondary storage and then brings it in to an empty page frame in the main memory. Then it updates the page table to indicate that the new data is in the main memory and returns the control back to the program that initially requested the page.

What is Swapping?

Swapping is the process of moving all the segments belonging to a process between the main memory and a secondary storage device. Swapping occurs under heavier work loads. Operating system kernel would move all the memory segments belonging to a process in to an area called swap area. When selecting a process for swapping, the operating system will select a process that will not become active for a while. When the main memory has enough space to hold the process, it will be transferred back in to the main memory from the swap space so that its execution could be continued.

What is the difference between Paging and Swapping?

In paging, blocks of equal size (called pages) are transferred between the main memory and a secondary storage device, while in swapping, all the segments belonging to a process will be moved back and forth between the main memory and a secondary storage device. Since paging allows moving pages (it could be a part of the address space of a process), it is more flexible than swapping. Since, paging only moves pages (unlike swapping, which move a whole process), paging would allow more processes to reside on the main memory at the same time, when compared with a swapping system. Swapping is more suitable when running heavier workloads.