Segmented Paging


In the operating system, segmented paging provides better performance and utilization of the CPU as it combines the process of segmentation and paging. Segmentation is termed a memory management technique where the memory is divided into segments that can be allocated to a process. These segments may not be in fixed length and not stored in a contagious manner. The segment table holds all the details relating to the segments and the processes. Generating a logical address which is converted to a physical address by the CPU by refereeing to the segment table. This table contains two fields about the segments and they are base and limit. Base or segment base denotes the base address of the segment which holds the initial physical address of segments and limit denotes the length of the segment.

Segmentation can be classified as virtual segmentation and simple segmentation, depending on how the processes are divided into segments and locating them in the memory area. Paging is a technique of fetching the process from the secondary memory into the memory. Here each process is divided into equal pages that are stored in non-contagious memory locations.

Segmented Paging

Paging has disadvantages in a situation when virtual address spaces are large, more space is occupied by pages in the main memory, and some addresses mapped may be invalid. To overcome this memory space issue segmented paging is used to reduce the size of the page table. In this technique, actual memory is divided into segments and these segments are divided into fixed-size pages. An input program or program which is stored in the memory is divided into four segments such as code, data, stack, and heap segment. This program can be divided into several segments, which are located inside the segment table.

segment table register and page mapping table are needed for implementing segmented paging. The virtual address is divided into three segments such as segment number, page number, and offset. Segment number refers to the corresponding segment table, which is used by the memory unit. The segmented table holds the base address of the page table and the limit. Each of the table entries points to the page table location that in turn maps to one of the pages inside the segment.

The figure below will give a clear representation of mapping using the segmented table.

Physical Address 

When a program starts its execution process, the CPU will generate a logical address for it. This address has two fields segment number and its offset. The value of the segment offset should be less than the limit. This logical address conversion happens with the help of a frame address, which can be taken from the segment table. Now the page table will point to the frame where the segment is located in the main memory. The logical address is a combination of segment number+ page number and its offset.

In simpler terms, a program is initially divided into various segments and each segment has a segment table associated for mapping purposes. This table stores the address of the page table. Finally, the page table has the frame address which points to the location of the main memory.

Advantages

  • Avoids external fragmentation due to fixed-size pages

  • It reduces the usage of memory and the allocation process is simpler.

  • The segment table has exactly one entry mapping to correspond to one segment

  • The size of the page table is reduced by using segmentation along with paging.

Disadvantages

  • Internal fragmentation exists.

  • The complexity of storage and accessing is higher than compared to the paging

  • It requires use of hardware resources.

  • Memory access time is higher as the sequential translation process is followed.

  • Page tables are stored in a contagious manner in the memory.

  • In the modern operating system used today, external fragmentation may also occur due to variations in page table size and segment table size.

Conclusion

Memory fragmentation is a major issue in the paging and segmentation process. To resolve these issues, both the techniques of segmentation and paging are combined to map the physical addresses. Segmentation technique is used for dividing the processes into smaller modules called segments and relative data are combined to form a single segment to load into the memory. The size of partitioning the modules depends on the length and type of the input processes. Segment tables are maintained to store information about the segments and their tasks. Each segment is associated with an entry inside the segment table and the page table is mapped to the respective segment and its frame. This frame address is used by the CPU to convert the logical or virtual address to a physical address, to locate the divided segments.

Updated on: 18-Jul-2023

548 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements