SlideShare a Scribd company logo
1 of 13
11/30/17 1
Paging and Segmentation
By
SATHISHKUMAR G
(sathishsak111@gmail.com)
11/30/17 2
Paging
• Goals
» make allocation and
swapping easier
• Make all chunks of
memory the same size
» call each chunk a
“PAGE”
» example page sizes are
512 bytes, 1K, 4K, 8K,
etc
» pages have been getting
bigger with time
» we’ll discuss reasons
why pages should be of
a certain size as the
week progresses.
Page # Offset
Virtual Address
Page
Table
Base
Register
+
+
=>
physical
address
Page Table
Each entry
in the page
table is a
“Page Table
Entry”
11/30/17 3
An Example
• Pages are 1024 bytes long
» this says that bottom 10 bits of the VA is the offset
• PTBR contains 2000
» this says that the first page table entry for this process is at physical
memory location 2000
• Virtual address is 2256
» this says “page 2, offset 256”
• Physical memory location 2004 contains 8192
» this says that each PTE is 4 bytes (1 word)
» and that the second page of this process’s address space can be
found at memory location 8192.
• So, we add 256 to 8192 and we get the real data!
11/30/17 4
What does a PTE contain?
M-bit V-bit Protection bits Page Frame Number
• The Modify bit says whether or not the page has been written.
» it is updated each time a WRITE to the page occurs.
• The Reference bit says whether or not the page has been touched
» it is updated each time a READ or a WRITE occurs
• The V bit says whether or not the PTE can be used
» it is checked each time the virtual address is used
• The Protection bits say what operations are allowed on this page
» READ, WRITE, EXECUTE
• The Page Frame Number says where in memory is the page
R-bit
1 1 1 1-2 about 20
11/30/17 5
Evaluating Paging
• Easy to allocate memory
» memory comes from a free list of fixed size chunks.
» to find a new page, get anything off the free list.
» external fragmentation not a problem
• easy to swap out pieces of a program
» since all pieces are the same size.
» use valid bit to detect references to swapped pages
» pages are a nice multiple of the disk block size.
• Can still have internal fragmentation
• Table space can become a serious problem
» especially bad with small pages
– eg, w/a 32bit address space and 1k size pages, that’s 222
pages or that many
ptes which is a lot!
• Memory reference overhead can be high
» 2 refs for every one
11/30/17 6
Segmentation and Paging
at the Same Time
• Provide for two levels of mapping
• Use segments to contain logically related things
» code, data, stack
» can vary in size but are generally large.
• Use pages to describe components of the segments
» makes segments easy to manage and can swap memory between
segments.
» need to allocate page table entries only for those pieces of the
segments that have themselves been allocated.
• Segments that are shared can be represented with shared page
tables for the segments themselves.
11/30/17 7
An Early Example -- IBM System 370
24 bit virtual address
4 bits 8 bits 12 bits
Segment
Table
Page Table
+
simple bit operation
Real Memory
11/30/17 8
Lookups
• Each memory reference can be 3
» assuming no fault
• Can exploit locality to improve lookup strategy
» a process is likely to use only a few pages at a time
• Use Translation Lookaside buffer to exploit locality
» a TLB is a fast associative memory that keeps track of recent translations.
• The hardware searches the TLB on a memory reference
• On a TLB miss, either a hardware or software exception can occur
» older machines reloaded the TLB in hardware
» newer RISC machines tend to use software loaded TLBs
– can have any structure you want for the page table
– fast handler computes and goes. Eg, the MIPS.
11/30/17 9
Hard versus soft page faults
• Hard page faults are those page faults that require issuing a
read from secondary storage.
• Soft page faults are those page faults where the page is already
in main memory however the TLB and/or the PTE has marked
the page as invalid.
» Soft faults are used when Hardware support is not available to
handle TLB misses
» Soft faults can also be used in implement certain page replacement
algorithms. More to come.
11/30/17 10
A TLB
• A small fully associative cache
• Each entry contains a tag and a
value.
» tags are virtual page numbers
» values are physical page table
entries.
• Problems include
» keeping the TLB consistent with
the PTE in main memory
– valid and ref bits, for example
» keeping TLBs consistent on an
MP.
» quickly loading the TLB on a
miss.
• Hit rates are important.
Tag Value
0xfff1000
0xfff1000
0xa10100
0xbbbb00
0x1111aa11
?
0x12341111
11/30/17 11
Selecting a page size
• Small pages give you lots of flexibility but at a high cost.
• Big pages are easy to manage, but not very flexible.
• Issues include
» TLB coverage
– product of page size and # entries
» internal fragmentation
– likely to use less of a big page
» # page faults and prefetch effect
– small pages will force you to fault often
» match to I/O bandwidth
– want one miss to bring in a lot of data since it will take a long time.
11/30/17 12
State of maintained by MM
• MM usually maintains a list of physical pages according to the
following attributes (various implementations use slightly
different lists)
» Zeroed pages
» Free pages
» Standby pages
» Modified pages
» Modified No Write pages
» Bad pages
• MM’s goal is to use these pages on these lists to supply
memory for both soft and hard page faults
• MM can have a modified page writer process that goes around
and flushes out dirty pages.
11/30/17 13
Thank you

More Related Content

What's hot

Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
C.U
 
Computer memory management
Computer memory managementComputer memory management
Computer memory management
Kumar
 

What's hot (20)

Segmentation geekssay.com
Segmentation  geekssay.comSegmentation  geekssay.com
Segmentation geekssay.com
 
Paging and Segmentation in Operating System
Paging and Segmentation in Operating SystemPaging and Segmentation in Operating System
Paging and Segmentation in Operating System
 
Operating system paging and segmentation
Operating system paging and segmentationOperating system paging and segmentation
Operating system paging and segmentation
 
Presentation on Segmentation
Presentation on SegmentationPresentation on Segmentation
Presentation on Segmentation
 
OSCh10
OSCh10OSCh10
OSCh10
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
 
Memory management
Memory managementMemory management
Memory management
 
Memory management
Memory managementMemory management
Memory management
 
ppt
pptppt
ppt
 
Computer memory management
Computer memory managementComputer memory management
Computer memory management
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Memory management
Memory managementMemory management
Memory management
 
Operating System- Multilevel Paging, Inverted Page Table
Operating System- Multilevel Paging, Inverted Page TableOperating System- Multilevel Paging, Inverted Page Table
Operating System- Multilevel Paging, Inverted Page Table
 
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
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memory
 
OS_Ch9
OS_Ch9OS_Ch9
OS_Ch9
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 

Similar to Paging and Segmentation

CS 542 Putting it all together -- Storage Management
CS 542 Putting it all together -- Storage ManagementCS 542 Putting it all together -- Storage Management
CS 542 Putting it all together -- Storage Management
J Singh
 

Similar to Paging and Segmentation (20)

Segmentation with paging methods and techniques
Segmentation with paging methods and techniquesSegmentation with paging methods and techniques
Segmentation with paging methods and techniques
 
Segmentation and paging
Segmentation and paging Segmentation and paging
Segmentation and paging
 
Ppt
PptPpt
Ppt
 
Operating system 35 paging
Operating system 35 pagingOperating system 35 paging
Operating system 35 paging
 
The life and times
The life and timesThe life and times
The life and times
 
Virtual memory translation.pptx
Virtual memory translation.pptxVirtual memory translation.pptx
Virtual memory translation.pptx
 
Unit-4 swapping.pptx
Unit-4 swapping.pptxUnit-4 swapping.pptx
Unit-4 swapping.pptx
 
Vm
VmVm
Vm
 
OS-01 Virtual Memory.pptx
OS-01 Virtual Memory.pptxOS-01 Virtual Memory.pptx
OS-01 Virtual Memory.pptx
 
Os4
Os4Os4
Os4
 
Os4
Os4Os4
Os4
 
Memory Management Strategies - III.pdf
Memory Management Strategies - III.pdfMemory Management Strategies - III.pdf
Memory Management Strategies - III.pdf
 
cache memory introduction, level, function
cache memory introduction, level, functioncache memory introduction, level, function
cache memory introduction, level, function
 
Optimizing Latency-sensitive queries for Presto at Facebook: A Collaboration ...
Optimizing Latency-sensitive queries for Presto at Facebook: A Collaboration ...Optimizing Latency-sensitive queries for Presto at Facebook: A Collaboration ...
Optimizing Latency-sensitive queries for Presto at Facebook: A Collaboration ...
 
Memory Management Strategies - IV.pdf
Memory Management Strategies - IV.pdfMemory Management Strategies - IV.pdf
Memory Management Strategies - IV.pdf
 
9 virtual memory management
9 virtual memory management9 virtual memory management
9 virtual memory management
 
Virtual Memory.pdf
Virtual Memory.pdfVirtual Memory.pdf
Virtual Memory.pdf
 
CAO-Unit-III.pptx
CAO-Unit-III.pptxCAO-Unit-III.pptx
CAO-Unit-III.pptx
 
Driver development – memory management
Driver development – memory managementDriver development – memory management
Driver development – memory management
 
CS 542 Putting it all together -- Storage Management
CS 542 Putting it all together -- Storage ManagementCS 542 Putting it all together -- Storage Management
CS 542 Putting it all together -- Storage Management
 

More from sathish sak

More from sathish sak (20)

TRANSPARENT CONCRE
TRANSPARENT CONCRETRANSPARENT CONCRE
TRANSPARENT CONCRE
 
Stationary Waves
Stationary WavesStationary Waves
Stationary Waves
 
Electrical Activity of the Heart
Electrical Activity of the HeartElectrical Activity of the Heart
Electrical Activity of the Heart
 
Electrical Activity of the Heart
Electrical Activity of the HeartElectrical Activity of the Heart
Electrical Activity of the Heart
 
Software process life cycles
Software process life cyclesSoftware process life cycles
Software process life cycles
 
Digital Logic Circuits
Digital Logic CircuitsDigital Logic Circuits
Digital Logic Circuits
 
Real-Time Scheduling
Real-Time SchedulingReal-Time Scheduling
Real-Time Scheduling
 
Real-Time Signal Processing: Implementation and Application
Real-Time Signal Processing:  Implementation and ApplicationReal-Time Signal Processing:  Implementation and Application
Real-Time Signal Processing: Implementation and Application
 
DIGITAL SIGNAL PROCESSOR OVERVIEW
DIGITAL SIGNAL PROCESSOR OVERVIEWDIGITAL SIGNAL PROCESSOR OVERVIEW
DIGITAL SIGNAL PROCESSOR OVERVIEW
 
FRACTAL ROBOTICS
FRACTAL  ROBOTICSFRACTAL  ROBOTICS
FRACTAL ROBOTICS
 
Electro bike
Electro bikeElectro bike
Electro bike
 
ROBOTIC SURGERY
ROBOTIC SURGERYROBOTIC SURGERY
ROBOTIC SURGERY
 
POWER GENERATION OF THERMAL POWER PLANT
POWER GENERATION OF THERMAL POWER PLANTPOWER GENERATION OF THERMAL POWER PLANT
POWER GENERATION OF THERMAL POWER PLANT
 
mathematics application fiels of engineering
mathematics application fiels of engineeringmathematics application fiels of engineering
mathematics application fiels of engineering
 
Plastics…
Plastics…Plastics…
Plastics…
 
ENGINEERING
ENGINEERINGENGINEERING
ENGINEERING
 
ENVIRONMENTAL POLLUTION
ENVIRONMENTALPOLLUTIONENVIRONMENTALPOLLUTION
ENVIRONMENTAL POLLUTION
 
RFID TECHNOLOGY
RFID TECHNOLOGYRFID TECHNOLOGY
RFID TECHNOLOGY
 
green chemistry
green chemistrygreen chemistry
green chemistry
 
NANOTECHNOLOGY
  NANOTECHNOLOGY	  NANOTECHNOLOGY
NANOTECHNOLOGY
 

Recently uploaded

Recently uploaded (20)

WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
WSO2Con2024 - Navigating the Digital Landscape: Transforming Healthcare with ...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital BusinessesWSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital Businesses
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
WSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in Uganda
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
WSO2Con2024 - Organization Management: The Revolution in B2B CIAM
WSO2Con2024 - Organization Management: The Revolution in B2B CIAMWSO2Con2024 - Organization Management: The Revolution in B2B CIAM
WSO2Con2024 - Organization Management: The Revolution in B2B CIAM
 
Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2Driving Innovation: Scania's API Revolution with WSO2
Driving Innovation: Scania's API Revolution with WSO2
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid Environments
 
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
 
AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdf
AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdfAzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdf
AzureNativeQumulo_HPC_Cloud_Native_Benchmarks.pdf
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 

Paging and Segmentation

  • 1. 11/30/17 1 Paging and Segmentation By SATHISHKUMAR G (sathishsak111@gmail.com)
  • 2. 11/30/17 2 Paging • Goals » make allocation and swapping easier • Make all chunks of memory the same size » call each chunk a “PAGE” » example page sizes are 512 bytes, 1K, 4K, 8K, etc » pages have been getting bigger with time » we’ll discuss reasons why pages should be of a certain size as the week progresses. Page # Offset Virtual Address Page Table Base Register + + => physical address Page Table Each entry in the page table is a “Page Table Entry”
  • 3. 11/30/17 3 An Example • Pages are 1024 bytes long » this says that bottom 10 bits of the VA is the offset • PTBR contains 2000 » this says that the first page table entry for this process is at physical memory location 2000 • Virtual address is 2256 » this says “page 2, offset 256” • Physical memory location 2004 contains 8192 » this says that each PTE is 4 bytes (1 word) » and that the second page of this process’s address space can be found at memory location 8192. • So, we add 256 to 8192 and we get the real data!
  • 4. 11/30/17 4 What does a PTE contain? M-bit V-bit Protection bits Page Frame Number • The Modify bit says whether or not the page has been written. » it is updated each time a WRITE to the page occurs. • The Reference bit says whether or not the page has been touched » it is updated each time a READ or a WRITE occurs • The V bit says whether or not the PTE can be used » it is checked each time the virtual address is used • The Protection bits say what operations are allowed on this page » READ, WRITE, EXECUTE • The Page Frame Number says where in memory is the page R-bit 1 1 1 1-2 about 20
  • 5. 11/30/17 5 Evaluating Paging • Easy to allocate memory » memory comes from a free list of fixed size chunks. » to find a new page, get anything off the free list. » external fragmentation not a problem • easy to swap out pieces of a program » since all pieces are the same size. » use valid bit to detect references to swapped pages » pages are a nice multiple of the disk block size. • Can still have internal fragmentation • Table space can become a serious problem » especially bad with small pages – eg, w/a 32bit address space and 1k size pages, that’s 222 pages or that many ptes which is a lot! • Memory reference overhead can be high » 2 refs for every one
  • 6. 11/30/17 6 Segmentation and Paging at the Same Time • Provide for two levels of mapping • Use segments to contain logically related things » code, data, stack » can vary in size but are generally large. • Use pages to describe components of the segments » makes segments easy to manage and can swap memory between segments. » need to allocate page table entries only for those pieces of the segments that have themselves been allocated. • Segments that are shared can be represented with shared page tables for the segments themselves.
  • 7. 11/30/17 7 An Early Example -- IBM System 370 24 bit virtual address 4 bits 8 bits 12 bits Segment Table Page Table + simple bit operation Real Memory
  • 8. 11/30/17 8 Lookups • Each memory reference can be 3 » assuming no fault • Can exploit locality to improve lookup strategy » a process is likely to use only a few pages at a time • Use Translation Lookaside buffer to exploit locality » a TLB is a fast associative memory that keeps track of recent translations. • The hardware searches the TLB on a memory reference • On a TLB miss, either a hardware or software exception can occur » older machines reloaded the TLB in hardware » newer RISC machines tend to use software loaded TLBs – can have any structure you want for the page table – fast handler computes and goes. Eg, the MIPS.
  • 9. 11/30/17 9 Hard versus soft page faults • Hard page faults are those page faults that require issuing a read from secondary storage. • Soft page faults are those page faults where the page is already in main memory however the TLB and/or the PTE has marked the page as invalid. » Soft faults are used when Hardware support is not available to handle TLB misses » Soft faults can also be used in implement certain page replacement algorithms. More to come.
  • 10. 11/30/17 10 A TLB • A small fully associative cache • Each entry contains a tag and a value. » tags are virtual page numbers » values are physical page table entries. • Problems include » keeping the TLB consistent with the PTE in main memory – valid and ref bits, for example » keeping TLBs consistent on an MP. » quickly loading the TLB on a miss. • Hit rates are important. Tag Value 0xfff1000 0xfff1000 0xa10100 0xbbbb00 0x1111aa11 ? 0x12341111
  • 11. 11/30/17 11 Selecting a page size • Small pages give you lots of flexibility but at a high cost. • Big pages are easy to manage, but not very flexible. • Issues include » TLB coverage – product of page size and # entries » internal fragmentation – likely to use less of a big page » # page faults and prefetch effect – small pages will force you to fault often » match to I/O bandwidth – want one miss to bring in a lot of data since it will take a long time.
  • 12. 11/30/17 12 State of maintained by MM • MM usually maintains a list of physical pages according to the following attributes (various implementations use slightly different lists) » Zeroed pages » Free pages » Standby pages » Modified pages » Modified No Write pages » Bad pages • MM’s goal is to use these pages on these lists to supply memory for both soft and hard page faults • MM can have a modified page writer process that goes around and flushes out dirty pages.