SlideShare a Scribd company logo
1 of 12
Segmentation

CS 537 – Introduction to Operating Systems
Segmentation
• Segmentation is a technique for breaking memory
  up into logical pieces
• Each “piece” is a grouping of related information
   –   data segments for each process
   –   code segments for each process
   –   data segments for the OS
   –   etc.
• Like paging, use virtual addresses and use disk to
  make memory look bigger than it really is
• Segmentation can be implemented with or without
  paging
Segmentation

      P1 data                              P2 code

                     print
                     function
                                     P2 data
   P1 code



OS Code             OS data               OS stack


             logical address space
Addressing Segments
• 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
Addressing Segments

                                     limit         base
    S             o

logical address


                                          segment table




                                    yes                   Physical Address
                        o < limit                    +

                        no

                         error
Segmentation Hardware
• Sounds very similar to paging
• Big difference – segments can be variable in size
• As with paging, to be effective hardware must be
  used to translate logical address
• Most systems provide segment registers
• If a reference isn’t found in one of the segment
  registers
   – trap to operating system
   – OS does lookup in segment table and loads new
     segment descriptor into the register
   – return control to the user and resume
• Again, similar to paging
Protection and Sharing
• Like page tables, each process usually gets
  its own segment table
• Unlike page tables, there usually exists a
  global segment table for everyone
  – this, however, is usually used by OS
• Access rights for segment are usually
  included in table entry
• Multiple processes can share a segment
Protection and Sharing

 limit base                   200
0 1000 200                   1200
1 3500 9000
                             2000
    LDT        limit base
                             2300
              0 500   2500   2500
              1 9000 20000   3000

                  GDT        9000
 limit base
0 1000 200
1 300 2000
                             12500
    LDT
Segmentation Issues
• 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 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
Linear Address
• The base address gotten from the segment
  descriptor table is concatenated with the
  offset
• This new address is often referred to as a
  linear address
• This is the address that is translated by the
  paging hardware
virtual address from user
      descriptor              offset




             limit   base                     +




             segment table

                 linear address   directory        page        offset
                                                                        page frame
                 PT directory                     page table




directory base

More Related Content

What's hot

Computer memory management
Computer memory managementComputer memory management
Computer memory management
Kumar
 
Combined paging and segmentation
Combined paging and segmentationCombined paging and segmentation
Combined paging and segmentation
Tech_MX
 
34 single partition allocation
34 single partition allocation34 single partition allocation
34 single partition allocation
myrajendra
 

What's hot (20)

Memory+management
Memory+managementMemory+management
Memory+management
 
Memory management
Memory managementMemory management
Memory management
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
 
Csc4320 chapter 8 2
Csc4320 chapter 8 2Csc4320 chapter 8 2
Csc4320 chapter 8 2
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Mca ii os u-4 memory management
Mca  ii  os u-4 memory managementMca  ii  os u-4 memory management
Mca ii os u-4 memory management
 
Memory management
Memory managementMemory management
Memory management
 
Computer memory management
Computer memory managementComputer memory management
Computer memory management
 
Paging,Segmentation & Segment with Paging
Paging,Segmentation & Segment with PagingPaging,Segmentation & Segment with Paging
Paging,Segmentation & Segment with Paging
 
Introduction of Memory Management
Introduction of Memory Management Introduction of Memory Management
Introduction of Memory Management
 
Memory management
Memory managementMemory management
Memory management
 
Combined paging and segmentation
Combined paging and segmentationCombined paging and segmentation
Combined paging and segmentation
 
34 single partition allocation
34 single partition allocation34 single partition allocation
34 single partition allocation
 
Operating system paging and segmentation
Operating system paging and segmentationOperating system paging and segmentation
Operating system paging and segmentation
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Memory management
Memory managementMemory management
Memory management
 
OS_Ch9
OS_Ch9OS_Ch9
OS_Ch9
 
Operation System
Operation SystemOperation System
Operation System
 
Memory management
Memory managementMemory management
Memory management
 
Memory management
Memory managementMemory management
Memory management
 

Similar to Segmentation geekssay.com

10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
Sher Shah Merkhel
 

Similar to Segmentation geekssay.com (20)

Segmentation
SegmentationSegmentation
Segmentation
 
PAGIN AND SEGMENTATION.docx
PAGIN AND SEGMENTATION.docxPAGIN AND SEGMENTATION.docx
PAGIN AND SEGMENTATION.docx
 
Os4
Os4Os4
Os4
 
Os4
Os4Os4
Os4
 
os presentation.ppt
os presentation.pptos presentation.ppt
os presentation.ppt
 
Segmentation
SegmentationSegmentation
Segmentation
 
Memory Management Strategies - III.pdf
Memory Management Strategies - III.pdfMemory Management Strategies - III.pdf
Memory Management Strategies - III.pdf
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
Lecture-7 Main Memroy.pptx
Lecture-7 Main Memroy.pptxLecture-7 Main Memroy.pptx
Lecture-7 Main Memroy.pptx
 
Ch8 main memory
Ch8   main memoryCh8   main memory
Ch8 main memory
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
Anshika 1111.pptx
Anshika 1111.pptxAnshika 1111.pptx
Anshika 1111.pptx
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
Main Memory
Main MemoryMain Memory
Main Memory
 
Memory Management.pdf
Memory Management.pdfMemory Management.pdf
Memory Management.pdf
 
Deep Dive into DynamoDB
Deep Dive into DynamoDBDeep Dive into DynamoDB
Deep Dive into DynamoDB
 
10 instruction sets characteristics
10 instruction sets characteristics10 instruction sets characteristics
10 instruction sets characteristics
 
Unit-4 swapping.pptx
Unit-4 swapping.pptxUnit-4 swapping.pptx
Unit-4 swapping.pptx
 
Segmentation in operating systems
Segmentation in operating systemsSegmentation in operating systems
Segmentation in operating systems
 

More from Hemant Gautam (8)

Make a fool geekssay.com sharing
Make a fool geekssay.com sharingMake a fool geekssay.com sharing
Make a fool geekssay.com sharing
 
1 men die-younger geekssay.com sharing
1 men die-younger geekssay.com sharing1 men die-younger geekssay.com sharing
1 men die-younger geekssay.com sharing
 
Shopping cart project geekssay.com
Shopping cart project geekssay.comShopping cart project geekssay.com
Shopping cart project geekssay.com
 
Atm traffic management geekssay.com
Atm traffic management  geekssay.comAtm traffic management  geekssay.com
Atm traffic management geekssay.com
 
Disk scheduling geekssay.com
Disk scheduling geekssay.comDisk scheduling geekssay.com
Disk scheduling geekssay.com
 
Kruskals prims shared by: geekssay.com
Kruskals prims shared by: geekssay.comKruskals prims shared by: geekssay.com
Kruskals prims shared by: geekssay.com
 
Knapsack Algorithm www.geekssay.com
Knapsack Algorithm www.geekssay.comKnapsack Algorithm www.geekssay.com
Knapsack Algorithm www.geekssay.com
 
College Monitoring system BY: Geekssay.com
College Monitoring system BY: Geekssay.comCollege Monitoring system BY: Geekssay.com
College Monitoring system BY: Geekssay.com
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 

Segmentation geekssay.com

  • 1. Segmentation CS 537 – Introduction to Operating Systems
  • 2. Segmentation • Segmentation is a technique for breaking memory up into logical pieces • Each “piece” is a grouping of related information – data segments for each process – code segments for each process – data segments for the OS – etc. • Like paging, use virtual addresses and use disk to make memory look bigger than it really is • Segmentation can be implemented with or without paging
  • 3. Segmentation P1 data P2 code print function P2 data P1 code OS Code OS data OS stack logical address space
  • 4. Addressing Segments • 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
  • 5. Addressing Segments limit base S o logical address segment table yes Physical Address o < limit + no error
  • 6. Segmentation Hardware • Sounds very similar to paging • Big difference – segments can be variable in size • As with paging, to be effective hardware must be used to translate logical address • Most systems provide segment registers • If a reference isn’t found in one of the segment registers – trap to operating system – OS does lookup in segment table and loads new segment descriptor into the register – return control to the user and resume • Again, similar to paging
  • 7. Protection and Sharing • Like page tables, each process usually gets its own segment table • Unlike page tables, there usually exists a global segment table for everyone – this, however, is usually used by OS • Access rights for segment are usually included in table entry • Multiple processes can share a segment
  • 8. Protection and Sharing limit base 200 0 1000 200 1200 1 3500 9000 2000 LDT limit base 2300 0 500 2500 2500 1 9000 20000 3000 GDT 9000 limit base 0 1000 200 1 300 2000 12500 LDT
  • 9. Segmentation Issues • 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
  • 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. Linear Address • The base address gotten from the segment descriptor table is concatenated with the offset • This new address is often referred to as a linear address • This is the address that is translated by the paging hardware
  • 12. virtual address from user descriptor offset limit base + segment table linear address directory page offset page frame PT directory page table directory base