1. Gyanastra
  2. Operating Systems
  3. Segmentation
  4. Segmentation with Paging
Free lesson, no account needed 7 min read 10 practice questions after it
Asked in past papers2 times
  • GATE CSE20061995

Operating Systems · Segmentation

Segmentation with Paging

Overview

Segmentation with paging is a memory-management scheme that combines segmentation and paging: the process is first divided into segments, and each segment is then divided into equal-sized pages.
It matters because it is the next most popular memory-management method after simple paging / virtual memory with paging, while pure segmentation is rarely used.

Key concepts

  • Segmentation with paging: a scheme that works like paging with one extra step; it is a kind of extension of multi-level paging.
  • Segments: the process is first divided into segments. Segments need not be of the same size, even if a diagram makes them appear equal.
  • Pages: each segment is then divided into equal-sized pages.
  • Frames: main memory is divided into frames, with page size equal to frame size.
  • Page table per segment: every segment has its own page table (S1 has PT1, S2 has PT2, S3 has PT3, S4 has PT4). This differs from simple paging, where the entire process had one single page table.
  • Page-table entry: if the page is in main memory, the entry gives the frame number; if the page is not in main memory, the entry says it is not present and it must be loaded, depending on how virtual memory is implemented.
  • Paged page tables: because paging is used, the page tables themselves must also be present in pages.
    In segmentation with paging, most implementations use only one level of paging, and the paging scheme is designed so that the page table of every segment fits in one page.
  • Popularity: simple paging / virtual memory with paging is the most popular method; segmentation with paging is the next popular method; pure segmentation is rarely used.

How it works

  1. Divide the process into segments, for example S1, S2, S3, S4. These segments need not be equal in size.
  2. Divide every segment into equal-sized pages. Divide main memory into frames such that pages and frames are equal in size.
    The operating system views memory loading in terms of pages and frames; segments do not directly determine how pages are loaded into main memory.
  3. When the CPU generates a logical address, the memory management unit (MMU) converts it into a physical address so that the required word can be fetched from main memory.
    The purpose of the MMU is to convert logical addresses generated by the CPU into physical addresses.
  4. For every segment, maintain one page table: PT1 for S1, PT2 for S2, PT3 for S3, PT4 for S4.
  5. The page table of a segment describes the pages present in that segment and where they are: the entry gives the frame number if the page is in main memory, or says the page is not present and must be loaded.
  6. The number of entries in a segment's page table equals the number of pages in that segment.
  7. Each page-table entry contains the frame number or frame base in which that page is loaded.
  8. Because the page tables are themselves paged, they must be loaded into pages/frames, and it is necessary to keep track of which frames contain these page tables.
    Earlier, with only one page table, the CPU used a register containing the base of the page table; with multiple page tables, the frame locations of all the page tables must be tracked.

Formulas

  • Entries in page table of segment SS = number of pages in segment SS
  • Page size = frame size
  • If there are NN segments, there are NN page tables, one per segment
  • If each segment's page table fits in one page, then NN page tables need NN pages/frames

Worked examples

Page-table entry count

  • A segment has 10 pages → its page table has 10 entries.
  • A segment has 20 pages → its page table has 20 entries.

Frame number stored in an entry

  • Segment S1 has pages numbered 0, 1, 2, 3.
  • Main memory has frames F1, F2, F3, F4, F5, F6, F7, F8.
  • Page number 0 of S1 is loaded in frame number 7, so the entry for page 0 in S1's page table stores frame number 7.

Page tables stored in frames

  • Four segments → four page tables.
  • Each page table is designed to fit in one page.
  • Therefore four pages/frames are needed to hold the four page tables.
  • The four page tables are loaded into four frames, and the system must track which frames contain them.
  • Earlier, with one page table, the CPU had a register containing the page-table base; with four page tables, all their frame locations must be tracked.

Comparison

MethodProcess divisionPage tablesUsage
Simple paging / virtual memory with pagingProcess divided into pagesOne single page table for the entire processMost popular
Segmentation with pagingProcess divided into segments; each segment divided into pagesOne page table per segmentNext popular
Pure segmentationProcess divided into segmentsNo per-segment page table in this schemeRarely used

Revision summary

  • Segmentation with paging = first divide the process into segments, then divide each segment into equal-sized pages.
  • Segments need not be equal in size; pages are equal-sized and match frame size.
  • Every segment has its own page table, with one entry per page in that segment.
  • Each entry stores the frame number/frame base of the page, or indicates that the page is not present in main memory.
  • Page tables themselves are paged; with one-level paging, design each segment's page table to fit in one page.
  • Four segments → four page tables → four pages/frames to hold the page tables.
  • With one page table, the CPU used a register for the page-table base; with multiple page tables, the frames holding all page tables must be tracked.
  • Popularity order: simple paging / virtual memory with paging is most popular; segmentation with paging is next; pure segmentation is rarely used.

Previous-year exam insights

  • In a paged segmentation scheme, the logical address is split as: segment number (index into the segment table) | page number within that segment (index into that segment's page table) | offset within the page.
    The segment table entry gives the base/size of that segment's page table, and the page-table entry gives the frame number.
    Asked inGATE 1995GATE 2006
  • If the segment table is very large it can itself be paged: the segment table's pages are then mapped through an additional page table into frames.
    This is optional and applies only when the segment table cannot reasonably be kept contiguous in memory.
    Asked inGATE 1995
  • Size of a segment table = (number of segments) × (size of one segment-table entry);
    size of a segment's page table = (number of pages in that segment) × (size of one page-table entry), where number of pages in a segment = ceil(segment size / page size).
    Asked inGATE 2006
  • Total memory for a process's tables in segmentation with paging = size of segment table + sum over all segments of that segment's page-table size.
    It can be smaller or larger than a single flat page table: only existing segments have page tables, so sparse address spaces save space, while per-segment tables add rounding overhead.
    Asked inGATE 2006
  • A segment's size is bounded by the maximum segment size; the number of pages in a segment is ceil(segment size / page size), and the page table must have one entry per page, so a larger maximum segment size means a larger possible page table per segment.
    Asked inGATE 2006
  • Segmentation with paging combines the programmer's view (logical segments) with the OS's view (fixed-size pages/frames), eliminating external fragmentation of pure segmentation while retaining logical modularity; internal fragmentation is limited to the last page of each segment.
Pages 1–2 of 2