Paging is not the same as segmentation. Paging is based on a purely physical
value: The program and main memory are divided up into the same physical size
chunks. Segmentation, on the other hand, allows for logical portions of the program
to be divided into variable-sized partitions. With segmentation, the user is
aware of the segment sizes and boundaries; with paging, the user is unaware of
the partitioning. Paging is easier to manage: allocation, freeing, swapping, and
relocating are easy when everything’s the same size. However, pages are typically
smaller than segments, which means more overhead (in terms of resources to
both track and transfer pages). Paging eliminates external fragmentation, whereas
segmentation eliminates internal fragmentation. Segmentation has the ability to
support sharing and protection, both of which are very difficult to do with paging.
Paging and segmentation both have their advantages; however, a system does
not have to use one or the other—these two approaches can be combined, in an
effort to get the best of both worlds. In a combined approach, the virtual address
space is divided into segments of variable length, and the segments are divided
into fixed-size pages. Main memory is divided into the same size frames.
Each segment has a page table, which means every program has multiple
page tables. The physical address is divided into three fields. The first field is the
segment field, which points the system to the appropriate page table. The second
field is the page number, which is used as an offset into this page table. The third
field is the offset within the page.
Combined segmentation and paging is very advantageous because it allows
for segmentation from the user’s point of view and paging from the system’s
point of view.