What are Paging and Segmentation in the operating system?
What are Paging and Segmentation in the operating system?
501
26-Mar-2023
Updated on 03-Apr-2023
Krishnapriya Rajeev
03-Apr-2023Paging and Segmentation are two memory management schemes used by operating systems to manage the memory of a computer system.
Paging: Paging is a memory management technique in which the physical memory of a computer is divided into fixed-size blocks called pages. The logical memory of a program is also divided into fixed-size blocks called frames. The pages of a program are mapped onto the frames of physical memory, and the mapping is maintained in a page table.
When a program references a memory address, the page table is used to translate the logical address into a physical address. If the required page is not in physical memory, a page fault occurs, and the page must be fetched from secondary storage into physical memory. Paging helps to reduce internal fragmentation and allows processes to use non-contiguous memory.
Paging provides better memory utilization and protection between processes, but it requires more overhead for maintaining the page table.
Segmentation: Segmentation is a memory management technique in which the logical memory of a program is divided into variable-size segments. Each segment represents a logical unit of the program, such as a code segment, a data segment, and a stack segment. Segmentation helps to reduce external fragmentation and allows the logical structure of a program to be more easily managed.
Each segment is allocated a contiguous block of physical memory, and the mapping between logical and physical addresses is maintained in a segment table. When a program references a memory address, the segment table is used to translate the logical address into a physical address. The segment table holds two key pieces of information related to a segment. Firstly, it contains the Base value which refers to the lowest address of the segment, and secondly, it holds the Limit value which specifies the size of the segment.
Segmentation provides better program structure and flexibility, but it can be less efficient in terms of memory utilization.