Page 133 - DCAP403_Operating System
P. 133
Operating System
Notes 7.5 Paging
It is 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 hard 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.
Figure 7.6: Paging
Paging
Page # Offset Virtual Address
18 14
Page Table
5 Page Table Entry (PTE)
Physical Memory
0 1 2 3 4 5 6
On operating systems, such as Windows NT, Windows 2000 or UNIX, the memory is logically
divided in pages. When the system needs a certain portion of memory which is currently in the
swap (this is called a page fault) it will load all the corresponding pages into RAM. When a page
is not accessed for a long time, it is saved back to disk and discarded.
126 LOVELY PROFESSIONAL UNIVERSITY