What are the differences between Swapping
and Paging
with reference to Process Memory Management
?
Also guide me to the tutorials if any where I could get more information.
A swapper manipulates entire processes, whereas a pager is concerned with the individual pages of a process. We thus use pager , rather than swapper, in connection with demand paging.
A swap file, sometimes called a page file or paging file, is space on a hard drive used as a temporary location to store information when RAM is fully utilized. Using a swap file, a computer can use more memory than what is physically installed in the computer.
Simply put, virtual memory is a combination of RAM and disk space that running processes can use. Swap space is the portion of virtual memory that is on the hard disk, used when RAM is full.
In Paging, a process address space is broken into fixed sized blocks called pages. In Segmentation, a process address space is broken in varying sized blocks called sections. 2. Accountability. Operating System divides the memory into pages.
Swapping refers to copying the entire process address space, or at any rate, the non-shareable-text data segment, out to the swap device, or back, in one go (typically disk).
Whereas paging refers to copying in/out one or more pages of the address space. In particular, this is at a much finer grain. For example, there are ~250,000 4 KB pages in a 1 GB RAM address space.
Swapping was used in the early days, e.g. DEC pdp-11 era Unix, 1975-80 ish. For all you could want to know and more, may I recommend The Lions Document a.k.a. Lions' Commentary on Unix 6th Ed. with Source Code, John Lions, ISBN 1-57398-013-7?
You will surely appreciate Chapter 14, "Program Swapping" which begins: "Unix, like all time-sharing systems, and some multiprogramming systems, uses "program swapping" (also called "roll-in/roll-out") to share the limited resource of the main physical memory among several processes."
Paging (on Unix) arrived with the BSD (Berkeley Systems Distribution) on the VAX-11/780 starting around 1980.
Paging is also usually associated with per-page memory attributes (no access, read-only, read-write, no execute, executable), and various virtual memory management tricks like demand-zero-filled pages, copy-on-write pages, and so forth.
Hardware-wise, swapping can be performed without any memory management HW whatsoever, although the early machines employed a simple memory mapping scheme (e.g. base and bound, or a simple one level fixed size page mapping table (e.g. divide the 64 KB data address space into 8, 8KB pages in a larger physical address space (256 KB ... 4 MB)).
In contrast, paging requires page-granularity virtual memory page table entries, which typically encode the physical address of the page, PTE bits such as valid, read, write, etc. The machine also needs to automatically (transparently to the application program) fetch and interpret page table entries as necessary to map each virtual address to its physical address, and/or take a page fault exception to enable the OS to make the page accessible and/or schedule an I/O to load it to physical RAM.
Happy hacking!
Although both terms are considered distinct by the, say, mainstream academic media, the fact is that some authors do use them as synonyms. To quote the excellent book on computers architectures written by David and Sarah Harris (Digital Design and Computer Architecture), "writing the physical page back to disk and reloading it with a different virtual page is called swapping,so the disk in a virtual memory system is sometimes called swap space". So, Tyler actually answered the question correctly and his answer should not be downvoted at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With