Recall that, as memory is allocated and freed using segmentation, the size of contiguous blocks of free memory tends to decrease. In other words, our memory becomes fragmented.
A far more efficient memory management technique is called paging. Paging differs from segmentation in two fundamental respects.
- Process information is stored in equal-sized blocks of memory known as pages
- Pages belonging to a given process are stored at non-contiguous addresses in physical memory
With paging, any data needing to be placed in or removed from memory will be a page-sized block of data. So, unlike with segmentation, the space between blocks of memory will never change. Since fragmentation was caused by these spaces tending to become smaller over time, paging does not risk the fragmentation problem.
Any benefit from paging would be lost, though, if the pages had to be stored in contiguous locations in memory. There is no difference between allocating 100 bytes of contiguous memory or 10 contiguous blocks of 10-byte-sized pages. So, the real power of paging comes from the ability to spread out a given processes’ memory across non-contiguous locations.
To add a wrinkle, though, we still want our process to think that the OS has allocated its memory contiguously. Therefore, we must use virtualization. Our OS gives each process a certain number of pages which are stored at contiguous addresses in virtual memory. So, from the process’ perspective, its memory is stored contiguously. Importantly though, these addresses in virtual memory need not map to contiguous addresses in physical memory.
Click Next when you’re ready to move on to the next exercise.