Segmentation, advantages, an example of segmentation in Operating Systems (OS)

Download This Tutorial in PDF

Segmentation, advantages, an example of segmentation in Operating Systems (OS).

In this tutorial, we will try to answer the following questions;

What is segmentation?

What are the advantages of segmentation?

Give an example of segmentation?

What is segmentation?

Segmentation is a memory management technique in which we divide the process  Read More  into smaller segments.  The process is segmented module by module. In main memory, we only store the segments of the process. Process segment table is used to keep the record of segments, its size, and its memory address.

Example of segmentation

segmentation os operating system advantages examples
Figure: segmentation os operating system advantages examples

In this example, the process is divided into three segments.

  • Size of segment 1 is 50KB
  • Segment 2 is of 100KB
  • Segment 3 is of 60KB. 
  • Segment 1 is stored on address 11
  • Segment 2 is stored on address 13
  • Segment 3 is stored on address 14

Memory segments in C program

memory segmentation in c

  1. Stack
  2. Heap
  3. Uninitialized data segment
  4. Initialized data segment
  5. Text

Stack Segment

The stack are used to keep the local data or local variables.

Example of Stack Segment


We can allocate the memory at run time with heap.

Example of Heap

Uninitialized data segment

In Uninitialized data segment, we have all uninitialized global and static variable.

Example of Uninitialized data segment

Initialized data segment

Initialized data segment contains the explicitly initialized global and static variables.

Example of Initialized data segment

Text Segment

The text segment are use to keep a binary of the compiled program.

Segmentation fault dynamic memory allocation | invalid memory reference

It is a recommended practice to initialize pointers with the value NULL, and set the pointer back to NULL when the pointer released the memory.
Suppose, we try to access data with the help of pointers and memory is not allocated for that pointer. This condition is called segmentation fault.

In a system employing a segmentation scheme for memory management wasted space is due to external fragmentation.

Differences between Segmentation VS Paging

Memory Sizea process address space is broken in varying sized memory blocks (segments).a process address space is partitioned into fixed sized memory blocks (pages).
SizeUser can determine Section size.We can determine Page size by available memory.
SpeedMemory access is slower in Segmentation.Memory access is faster in Paging.
AccountabilityCompiler  helps to find the segment size, actual address and the virtual address.OS divides the memory into pages.
Logical AddressLogical address is divided into section number and section offset.Logical address is divided into page number and page offset.
FragmentationSegmentation is a possible reason of external fragmentation.Paging is a possible reason of internal fragmentation.

What are advantages of segmentation?

  • The segment table is used to keep the record of segments and segment table occupies less space as compared to the paging table.
  • No internal fragmentation.  Read More 

    What are disadvantages of segmentation?

    • Due to segments external fragmentation occurs and external fragmentation results in a lot of memory waste.

Video Lecture

Subscribe for Friendship

Latest posts by Prof. Fazal Rehman Shamil (see all)

Buy advertisement space on T4Tutorials

For more details email [email protected]