Skip to main content
Engineering LibreTexts

12.7: Segmentation

  • Page ID
    82910
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Segmentation in Operating System

    A process is divided into segments. The segments are not required to be of the same sizes. 

    There are 2 types of segmentation:

    1. Virtual memory segmentation 
      Each process is divided into a number of segments, not all of which are resident at any one point in time.
    2. Simple segmentation 
      Each process is divided into a number of segments, all of which are loaded into memory at run time, though not necessarily contiguously.

    There is no simple relationship between logical addresses and physical addresses in segmentation. A table stores the information about all such segments and is called Segment Table.

    segmentation.png
    Figure \(\PageIndex{1}\): Segmentation Table Mapping to Physical Address. 
    ("Segmentation Table Mapping to Physical Address" by VaibhavRai3Geeks for Geeks is licensed under CC BY-SA 4.0)

    The Segment Table maps the logical address, made up of the base address and the limit, into one-dimensional physical address. It’s each table entry has:

    • Base Address: It contains the starting physical address where the segments reside in memory.
    • Limit: It specifies the length of the segment.

    Translation of a two dimensional Logical Address to one dimensional Physical Address.

    Translation (1).png
    Figure \(\PageIndex{1}\): Translate Logical Address to Physical Address. 
    ("Translate Logical Address to Physical Address" by VaibhavRai3Geeks for Geeks is licensed under CC BY-SA 4.0)

    Address generated by the CPU is divided into:

    • Segment number (s): Number of bits required to represent the segment.
    • Segment offset (d): Number of bits required to represent the size of the segment.

    Walking through the diagram above:

    1. CPU generates a 2 part logival address. 
    2. The segment number is used to get the Limit and the Base Address value from the segment table.
    3. If the segment offset (d) is less than the Limit value from the segment table then
      • The Base Address returned from the segment table, points to the beginning of the segment
      • The Limit value points to the end of the segment in physcial memory.

    Advantages of Segmentation

    • No Internal fragmentation.
    • Segment Table consumes less space in comparison to Page table in paging.

    Disadvantage of Segmentation

    • As processes are loaded and removed from the memory, the free memory space is broken into little pieces, causing External fragmentation.

    Adapted from:
    "Segmentation in Operating System" by VaibhavRai3Geeks for Geeks is licensed under CC BY-SA 4.0


    This page titled 12.7: Segmentation is shared under a CC BY-SA license and was authored, remixed, and/or curated by Patrick McClanahan.

    • Was this article helpful?