What is segmentation
Segmentation is a technique to break
memory into logical pieces where each
piece represents a group of related
information.
Why is Segmentation used?
• Segmentation is one of the most common ways to achieve memory
protection
• Because internal fragmentation of pages takes place ,the user’s view of
memory is lost
• The user will view the memory as a combination of segments
• In this type, memory address used are not
contiguous.
• Each memory segment is associated with specific length and set of
permission
• When a process tries to access the memory it is first checked to see
whether it has the required permission to access the particular memory
segment by the particular memory
Segmentation
• Process are allocated with
segments
• Segment that the process
needs like
heap,stack,code,data are
divided into segments
• Segments make the
process more organized
• Logical view- multiple
separate segments
• Typical- code,data,stack
• Others-memory sharing etc
Memory Segmentation in 8086
Segmentation Architecture
• Each segment has
contiguous memory
• Logical address consists of
a two tuple: <segment-
number, offset>,
• Segment table – maps
two-dimensional physical
addresses; each table
entry has:
• 1. base – contains the
starting physical address
where the segments
reside in memory.
• 2. limit – specifies the
length of the segment.
Segmentation Hardware
Segmentation Hardware
• Let’s first assume no paging in the system
• User generates logical addresses
• These addresses consist of a segment number and an
offset into the segment
• Use segment number to index into a table
• Table contains the physical address of the start of the
segment
– often called the base address
• Add the offset to the base and generate the physical
address
– before doing this, check the offset against a limit
– the limit is the size of the segment
Segmentation with paging
Segmentation with Paging
Segmentation with Paging
• Most architectures support segmentation and paging
• Basic idea,
– segments exist in virtual address space
– base address in segment descriptor table is a
virtual address
– use paging mechanism to translate this virtual
address into a physical address
• Now an entire segment does not have to be in
memory at one time
– only the part of the segment that we need will be
in memory
Segmentation with Paging
Example of
Segmentation
Segment Protection
Protection: How does one process ensure that no
other process can access its memory? OS make sure
that it never creates a segment table entry that
points to same physical memory
Segment Sharing
Segmentation issue
• Entire segment is either in memory or on disk
• Variable sized segments leads to external
fragmentation in memory
• Must find a space big enough to place
segment into
• May need to swap out some segments to
bring a new segment in
Segmentation Over Paging
• Paging:
Fixed Size
Transparent to programmer (system allocates memory)
No separate protection
No separate compiling
No shared code
Internal Fragmentation take paces
• Segmentation:
Involves programmer (allocates memory to specific function inside code)
Separate compiling
Separate protection
Share code
Variable Size
Internal l Fragmentation does not take place
Thank You

Presentation on Segmentation

  • 1.
    What is segmentation Segmentationis a technique to break memory into logical pieces where each piece represents a group of related information.
  • 2.
    Why is Segmentationused? • Segmentation is one of the most common ways to achieve memory protection • Because internal fragmentation of pages takes place ,the user’s view of memory is lost • The user will view the memory as a combination of segments • In this type, memory address used are not contiguous. • Each memory segment is associated with specific length and set of permission • When a process tries to access the memory it is first checked to see whether it has the required permission to access the particular memory segment by the particular memory
  • 3.
    Segmentation • Process areallocated with segments • Segment that the process needs like heap,stack,code,data are divided into segments • Segments make the process more organized • Logical view- multiple separate segments • Typical- code,data,stack • Others-memory sharing etc
  • 4.
  • 5.
    Segmentation Architecture • Eachsegment has contiguous memory • Logical address consists of a two tuple: <segment- number, offset>, • Segment table – maps two-dimensional physical addresses; each table entry has: • 1. base – contains the starting physical address where the segments reside in memory. • 2. limit – specifies the length of the segment.
  • 6.
  • 7.
    Segmentation Hardware • Let’sfirst assume no paging in the system • User generates logical addresses • These addresses consist of a segment number and an offset into the segment • Use segment number to index into a table • Table contains the physical address of the start of the segment – often called the base address • Add the offset to the base and generate the physical address – before doing this, check the offset against a limit – the limit is the size of the segment
  • 8.
  • 9.
  • 10.
    Segmentation with Paging •Most architectures support segmentation and paging • Basic idea, – segments exist in virtual address space – base address in segment descriptor table is a virtual address – use paging mechanism to translate this virtual address into a physical address • Now an entire segment does not have to be in memory at one time – only the part of the segment that we need will be in memory
  • 11.
  • 12.
  • 13.
    Segment Protection Protection: Howdoes one process ensure that no other process can access its memory? OS make sure that it never creates a segment table entry that points to same physical memory
  • 14.
  • 15.
    Segmentation issue • Entiresegment is either in memory or on disk • Variable sized segments leads to external fragmentation in memory • Must find a space big enough to place segment into • May need to swap out some segments to bring a new segment in
  • 17.
    Segmentation Over Paging •Paging: Fixed Size Transparent to programmer (system allocates memory) No separate protection No separate compiling No shared code Internal Fragmentation take paces • Segmentation: Involves programmer (allocates memory to specific function inside code) Separate compiling Separate protection Share code Variable Size Internal l Fragmentation does not take place
  • 18.