Paging
<operating system> A technique for increasing the memory space available by moving infrequently-used parts of a program's working memory from
RAM to a secondary storage medium, usually disk.
The unit of transfer is called a page.
A
memory management unit (MMU) monitors accesses to memory and splits each address into a page number (the most significant bits) and an offset within that page (the lower bits).
It then looks up the page number in its page table. The page may be marked as paged in or paged out.
If it is paged in then the memory access can proceed after translating the
virtual address to a
physical address.
If the requested page is paged out then space must be made for it by paging out some other page, i.e. copying it to disk.
The requested page is then located on the area of the disk allocated for "
swap space" and is read back into
RAM.
The page table is updated to indicate that the page is paged in and its physical address recorded.
The MMU also records whether a page has been modified since it was last paged in.
If it has not been modified then there is no need to copy it back to disk and the space can be reused immediately.
Paging allows the total memory requirements of all running tasks (possibly just one) to exceed the amount of
physical memory, whereas
swapping simply allows multiple processes to run concurrently, so long as each process on its own fits within
physical memory.