Paging and Segmentation in Operating Systems
Paging is a memory management technique in which both physical and logical memory are divided into fixed-size blocks. The logical blocks are called pages, and the physical blocks are called frames. When a process is executed, its pages are mapped to available frames in physical memory using a page table. Since pages and frames are of the same size, this approach eliminates external fragmentation, but internal fragmentation can still occur when the last frame is not completely filled. Paging makes memory allocation simple and efficient, but the overhead of maintaining page tables is a drawback.
Segmentation, on the other hand, divides memory into variable-sized blocks known as segments, which are based on the logical divisions of a program, such as functions, arrays, or the stack. Each segment has a base address and a limit that define where it is located in physical memory and how large it is. A logical address in segmentation consists of a segment number and an offset within that segment. This method aligns closely with how programmers logically structure their code, making it easier to manage protection and sharing of modules. However, segmentation can lead to external fragmentation since segments are not of uniform size.
The main difference between paging and segmentation is that paging works with fixed-size blocks and is designed for system efficiency, while segmentation works with variable-sized blocks and is designed to match the programmer’s logical view of memory. Paging may cause internal fragmentation, whereas segmentation may cause external fragmentation. Paging uses a page table for address translation, while segmentation uses a segment table with base and limit values. From the user’s perspective, paging gives the impression of a linear memory space, while segmentation reflects the logical structure of the program.
In short, paging focuses on the needs of the operating system, while segmentation focuses on the needs of the programmer.
Social Plugin