SEGMENTATION
Memory Segmentation
1
Introduction
Segmentation is the process in which the main memory of the computer is divided into
different sectors or segments. It is basically used to enhance the speed of execution of the
computer system
2
TYPES OF SEGMENTATION
3
Memory has four types of segmentation:
■ Code Segment
■ Data Segment
■ Stack Segment
■ Extra Segment
3
4
TYPES OF SEGMENTATION
■ Code segment register (CS): is used fro addressing memory location in the code
segment of the memory, where the executable program is stored.
■ Data segment register (DS): points to the data segment of the memory where the
data is stored.
■ Extra Segment Register (ES): also refers to a segment in the memory which is
another data segment in the memory.
■ Stack Segment Register (SS): is used fro addressing stack segment of the memory.
The stack segment is that segment of memory which is used to store stack data.
4
Overlapped & Non Overlapped
Segment
■ Overlapping segment : A segment starts at a particular address and its maximum
size can go up to 64 Kbytes. But if another segment starts along this 64 Kbytes
location of the first segment, the two segments are said to be overlapping segment
■ Non Overlapped Segment : A segment starts at a particular address and its
maximum size can go up to 64 Kbytes. But if another segment starts before this 64
Kbytes location of the first segment, the two segments are said to be Non-
overlapping segment.
5
Example of Segmentation
6
Segmentation & paging comparison
7
Segmentation Paging
Segments are variable-size Pages are fixed-size.
Supports protection/sharing.
Segmentation is visible to the programmer Paging is transparent.
Segmentation requires more complicated hardware for address translation than paging.
Segmentation suffers from external
fragmentation.
Paging only yields a small internal
fragmentation.
Free memory is quickly allocated to a
process.
Lengthy searchTime when allocating a
process
Segment protection
Segment protection is a type of backup technique that can be used in
most networks. It can be implemented as a dedicated backup or as a
shared backup protection.
8
Sharing
■ Sharing can be achieved by segments referencing multiple processes.
■ Two processes that need to share access to a single segment would
have the same segment name and address in their segment tables.
■ Since segments vary in length, memory allocation is a dynamic storage-
allocation problem.
9
LogicalView of Segmentation
Symbol table
All Icon
Main program
Segment Offset
Segment number
Memory Management Unit
10
SegmentationArchitecture
11
Basic SegmentationArchitecture :
12
Advantages of segmentation
■ No Internal fragmentation.
■ Allows the memory capacity to be 1 Mbyte although the actual addresses to be handled are
of 16-bit size.
■ Allow the use of separate memory areas for the program code and data and stack portion
of the program.
■ logical addressed can be loaded into the instruction pointer (IP) and run the program
anywhere in the segment memory as the logical address varies from 0000H to FFFFH.
13
Advantages
■ Programs are re-locatable so that programs can be run at any location in the memory.
■ Average segment size >> average page size
■ Multitasking becomes easy
14
Disadvantage of Segmentation
 External fragmentation.
 As processes are loaded and removed from the memory, the free memory space
is broken into little pieces, causing External fragmentation.
 Segmentation: find free memory area big enough.
15
Disadvantage
 Paging: keep list of free pages, any page is ok.
 Segments of unequal size not suited as well for swapping.
 Costly memory management algorithms.
16
17
THANK
YOU

Segmentation

  • 1.
  • 2.
    Introduction Segmentation is theprocess in which the main memory of the computer is divided into different sectors or segments. It is basically used to enhance the speed of execution of the computer system 2
  • 3.
    TYPES OF SEGMENTATION 3 Memoryhas four types of segmentation: ■ Code Segment ■ Data Segment ■ Stack Segment ■ Extra Segment 3
  • 4.
    4 TYPES OF SEGMENTATION ■Code segment register (CS): is used fro addressing memory location in the code segment of the memory, where the executable program is stored. ■ Data segment register (DS): points to the data segment of the memory where the data is stored. ■ Extra Segment Register (ES): also refers to a segment in the memory which is another data segment in the memory. ■ Stack Segment Register (SS): is used fro addressing stack segment of the memory. The stack segment is that segment of memory which is used to store stack data. 4
  • 5.
    Overlapped & NonOverlapped Segment ■ Overlapping segment : A segment starts at a particular address and its maximum size can go up to 64 Kbytes. But if another segment starts along this 64 Kbytes location of the first segment, the two segments are said to be overlapping segment ■ Non Overlapped Segment : A segment starts at a particular address and its maximum size can go up to 64 Kbytes. But if another segment starts before this 64 Kbytes location of the first segment, the two segments are said to be Non- overlapping segment. 5
  • 6.
  • 7.
    Segmentation & pagingcomparison 7 Segmentation Paging Segments are variable-size Pages are fixed-size. Supports protection/sharing. Segmentation is visible to the programmer Paging is transparent. Segmentation requires more complicated hardware for address translation than paging. Segmentation suffers from external fragmentation. Paging only yields a small internal fragmentation. Free memory is quickly allocated to a process. Lengthy searchTime when allocating a process
  • 8.
    Segment protection Segment protectionis a type of backup technique that can be used in most networks. It can be implemented as a dedicated backup or as a shared backup protection. 8
  • 9.
    Sharing ■ Sharing canbe achieved by segments referencing multiple processes. ■ Two processes that need to share access to a single segment would have the same segment name and address in their segment tables. ■ Since segments vary in length, memory allocation is a dynamic storage- allocation problem. 9
  • 10.
    LogicalView of Segmentation Symboltable All Icon Main program Segment Offset Segment number Memory Management Unit 10
  • 11.
  • 12.
  • 13.
    Advantages of segmentation ■No Internal fragmentation. ■ Allows the memory capacity to be 1 Mbyte although the actual addresses to be handled are of 16-bit size. ■ Allow the use of separate memory areas for the program code and data and stack portion of the program. ■ logical addressed can be loaded into the instruction pointer (IP) and run the program anywhere in the segment memory as the logical address varies from 0000H to FFFFH. 13
  • 14.
    Advantages ■ Programs arere-locatable so that programs can be run at any location in the memory. ■ Average segment size >> average page size ■ Multitasking becomes easy 14
  • 15.
    Disadvantage of Segmentation External fragmentation.  As processes are loaded and removed from the memory, the free memory space is broken into little pieces, causing External fragmentation.  Segmentation: find free memory area big enough. 15
  • 16.
    Disadvantage  Paging: keeplist of free pages, any page is ok.  Segments of unequal size not suited as well for swapping.  Costly memory management algorithms. 16
  • 17.