SlideShare a Scribd company logo
1 of 17
2
 Recall: memory allocation with variable partitions requires mapping logical
addresses to physical addresses
 Virtual memory achieves a complete separation of logical and physical address-
spaces
 Typically a virtual address is 32 bits, this allows a process to have 4GB of virtual
memory
 Physical memory is much smaller than this, and varies from machine to machine
 Virtual address spaces of different processes are distinct
 Structuring of virtual memory
 Paging: Divide the address space into fixed-size pages
 Segmentation: Divide the address space into variable-size segments
(corresponding to logical units)
Concept of Virtual Memory
Virtual Memory Organization
 Benefits of Virtual Memory ::
 Less I/O needed to load / swap a process.
 Degree of multiprogramming can be increased.
 A program’s logical address space can be larger than physical memory.
 How do we know if a page is in main memory or not?
 With each page table entry, a valid–invalid bit is associated
(1  legal/in-memory , 0  not-in-memory)
 During address translation, if valid–invalid bit in page table entry is 0  page fault trap
1
1
1
1
0
0
0

Frame # valid-invalid bit
page table
Dirty bit in Page table
 Hardware traps to kernel on page fault
 CPU registers of current process are saved
 OS determines which virtual page needed
 OS checks validity of address, protection status
 Check if there is a free frame, else invoke page replacement policy to
select a frame
 If selected frame is dirty, write it to disk
 When page frame is clean, schedule I/O to read in page
 Page table updated
 Process causing fault rescheduled
 Instruction causing fault reinstated
 Registers restored, and program continues execution
GMU – CS 571
Steps in Handling a Page Fault
GMU – CS 571
Impact of Page Faults
 Each page fault affects the system performance negatively
 The process experiencing the page fault will not be able to continue until
the missing page is brought to the main memory
 The process will be blocked (moved to the waiting state) so its data
(registers, etc.) must be saved.
 Dealing with the page fault involves disk I/O
 Increased demand to the disk drive
 Increased waiting time for process experiencing the page fault
Page-Fault Frequency Scheme
 Establish “acceptable” page-fault rate.
 If actual rate too low, process loses frame.
 If actual rate too high, process gains frame.
12
 To avoid thrashing (i.e. too many page faults), a process needs “enough” pages in
the memory
 Memory accesses by a program are not spread all over its virtual memory
randomly, but show a pattern
 E.g. while executing a procedure, a program is accessing the page that contains
the code of the procedure, the local variables, and global vars.
 This is called locality of reference.
 How to exploit locality?
 PrePaging : when a process is brought into memory by the swapper, a few
pages are loaded in a priory (note: demand paging means that a page is
brought in only when needed)
 Working set: Try to keep currently used pages in memory
13
 The phenomenon that programs actually use only a limited set of pages during any
particular time period of execution.
 This set of pages is called the locality of the program during that time.
 Ex. Program phase diagram
virtual
address --------------------------
5 | | x | x | |
--------------------------
4 | | x | x | |
--------------------------
segments 3 | x | x | x | x |
--------------------------
2 x | x | | x | x |
--------------------------
1 x | x | | | |
1 2 3 4 5 virtual
phases time
14
 Working set of a process at time t is the set of pages referenced over last k
accesses (here, k is a parameter)
 Goal of working set based algorithms: keep the working set in memory, and
replace pages not in the working set
 Maintaining the precise working set not feasible (since we don’t want to update
data structures upon every memory access)
 Compromise: Redefine working set to be the set of pages referenced over last m
clock cycles
 Recall: clock interrupt happens every 40 ms and OS can check if the page has
been referenced during the last cycle (R=1)
15
 The working set of a process is the set of all pages accessed by the process within some
fixed time window.
Locality of reference means that a process's working set is usually small compared to
the total number of pages it possesses.
 A program's working set at the k-th reference with window size h is defined to be
W(k,h) = { i  N | page i appears among rk-h+1 … rk }
 The working set at time t is
W(t,h) = W(k,h) where time(rk)  t < t(rk+1)
 Ex. h=4
 w = 1 2 3 4 1 2 5 1 2 5 3 2
| | | | | | | | | | | |
{1} | | | | | | | | | | |
{1,2}| {1,2,3,4} | {1,2,5} | |
{1,2,3} {1,2,4,5} {1,2,3,5}
  = working-set window = a fixed number of page references
Example: 10,000 instruction
 WSSi (working set of Process Pi) =
total number of pages referenced in the most recent  (varies in time)
 if  too small will not encompass entire locality.
 if  too large will encompass several localities.
 if  =   will encompass entire program.
 D =  WSSi  total demand frames
 if D > m  Thrashing
 Policy if D > m, then suspend one of the processes.
Working Sets and Page Fault Rates

More Related Content

What's hot

Virtual memory
Virtual memoryVirtual memory
Virtual memory
Anuj Modi
 

What's hot (20)

Presentation on Virtual Memory concepts in computer
Presentation on Virtual Memory concepts in computer Presentation on Virtual Memory concepts in computer
Presentation on Virtual Memory concepts in computer
 
Virtual Memory ,Direct memory addressing and indirect memory addressing prese...
Virtual Memory ,Direct memory addressing and indirect memory addressing prese...Virtual Memory ,Direct memory addressing and indirect memory addressing prese...
Virtual Memory ,Direct memory addressing and indirect memory addressing prese...
 
Computer architecture virtual memory
Computer architecture virtual memoryComputer architecture virtual memory
Computer architecture virtual memory
 
Virtual memory ppt
Virtual memory pptVirtual memory ppt
Virtual memory ppt
 
Memory Hierarchy
Memory HierarchyMemory Hierarchy
Memory Hierarchy
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Page replacement
Page replacementPage replacement
Page replacement
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Memory organization
Memory organizationMemory organization
Memory organization
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managment
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Operating system 37 demand paging
Operating system 37 demand pagingOperating system 37 demand paging
Operating system 37 demand paging
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithm
 
Paging and Segmentation
Paging and SegmentationPaging and Segmentation
Paging and Segmentation
 
1.prallelism
1.prallelism1.prallelism
1.prallelism
 
Swapping | Computer Science
Swapping | Computer ScienceSwapping | Computer Science
Swapping | Computer Science
 
Memory hierarchy unit 2 by ram k paliwal
Memory hierarchy  unit 2 by ram k paliwalMemory hierarchy  unit 2 by ram k paliwal
Memory hierarchy unit 2 by ram k paliwal
 

Viewers also liked

15. Computer Systems Basic Software 1
15. Computer Systems   Basic Software 115. Computer Systems   Basic Software 1
15. Computer Systems Basic Software 1
New Era University
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
Mohd Arif
 
Operating system introduction to operating system
Operating system   introduction to operating systemOperating system   introduction to operating system
Operating system introduction to operating system
jaydeesa17
 
39 virtual memory
39 virtual memory39 virtual memory
39 virtual memory
myrajendra
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
vatsaanadi
 

Viewers also liked (20)

Vm
VmVm
Vm
 
Operating Systems - Virtual Memory
Operating Systems - Virtual MemoryOperating Systems - Virtual Memory
Operating Systems - Virtual Memory
 
VIRTUAL MEMORY
VIRTUAL MEMORYVIRTUAL MEMORY
VIRTUAL MEMORY
 
Virtual memory ppt
Virtual memory pptVirtual memory ppt
Virtual memory ppt
 
Virtual memory 20070222-en
Virtual memory 20070222-enVirtual memory 20070222-en
Virtual memory 20070222-en
 
Ch10: Virtual Memory
Ch10: Virtual MemoryCh10: Virtual Memory
Ch10: Virtual Memory
 
Ch09
Ch09Ch09
Ch09
 
virtual memory
virtual memoryvirtual memory
virtual memory
 
Os8
Os8Os8
Os8
 
Virtual Memory (Making a Process)
Virtual Memory (Making a Process)Virtual Memory (Making a Process)
Virtual Memory (Making a Process)
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
15. Computer Systems Basic Software 1
15. Computer Systems   Basic Software 115. Computer Systems   Basic Software 1
15. Computer Systems Basic Software 1
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Device Management
Device ManagementDevice Management
Device Management
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Operating system introduction to operating system
Operating system   introduction to operating systemOperating system   introduction to operating system
Operating system introduction to operating system
 
39 virtual memory
39 virtual memory39 virtual memory
39 virtual memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
virtual memory
virtual memoryvirtual memory
virtual memory
 

Similar to basics of virtual memory

Ch10 OS
Ch10 OSCh10 OS
Ch10 OS
C.U
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
C.U
 

Similar to basics of virtual memory (20)

Unit 5Memory management.pptx
Unit 5Memory management.pptxUnit 5Memory management.pptx
Unit 5Memory management.pptx
 
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
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
 
OSCh10
OSCh10OSCh10
OSCh10
 
Ch10 OS
Ch10 OSCh10 OS
Ch10 OS
 
OS_Ch10
OS_Ch10OS_Ch10
OS_Ch10
 
OS_Ch9
OS_Ch9OS_Ch9
OS_Ch9
 
OSCh9
OSCh9OSCh9
OSCh9
 
Ch9 OS
Ch9 OSCh9 OS
Ch9 OS
 
CH09.pdf
CH09.pdfCH09.pdf
CH09.pdf
 
Mem mgt
Mem mgtMem mgt
Mem mgt
 
Memory management
Memory managementMemory management
Memory management
 
Virtual memory - Demand Paging
Virtual memory - Demand PagingVirtual memory - Demand Paging
Virtual memory - Demand Paging
 
Memory management
Memory managementMemory management
Memory management
 
Virtual memory This is the operating system ppt.ppt
Virtual memory This is the operating system ppt.pptVirtual memory This is the operating system ppt.ppt
Virtual memory This is the operating system ppt.ppt
 
Memory+management
Memory+managementMemory+management
Memory+management
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
 
Ch8
Ch8Ch8
Ch8
 
Virtual memory pre-final-formatting
Virtual memory pre-final-formattingVirtual memory pre-final-formatting
Virtual memory pre-final-formatting
 
Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858
 

More from Adarsh Patel

projection of solid
projection of solidprojection of solid
projection of solid
Adarsh Patel
 
basic electronics, Transmission lines, wave guides And Antenna fundamental
basic electronics, Transmission lines, wave guides And Antenna fundamentalbasic electronics, Transmission lines, wave guides And Antenna fundamental
basic electronics, Transmission lines, wave guides And Antenna fundamental
Adarsh Patel
 

More from Adarsh Patel (14)

CMACs and MACS based on block ciphers, Digital signature
CMACs and MACS based on block ciphers, Digital signatureCMACs and MACS based on block ciphers, Digital signature
CMACs and MACS based on block ciphers, Digital signature
 
4G 5G technology
4G 5G technology 4G 5G technology
4G 5G technology
 
jstl ( jsp standard tag library )
jstl ( jsp standard tag library )jstl ( jsp standard tag library )
jstl ( jsp standard tag library )
 
Loaders ( system programming )
Loaders ( system programming ) Loaders ( system programming )
Loaders ( system programming )
 
Non Linear Data Structures
Non Linear Data StructuresNon Linear Data Structures
Non Linear Data Structures
 
8255:ppi & 8259:pic
8255:ppi & 8259:pic 8255:ppi & 8259:pic
8255:ppi & 8259:pic
 
case study of curve fitting
case study of curve fittingcase study of curve fitting
case study of curve fitting
 
synchronous state machine design
synchronous state machine designsynchronous state machine design
synchronous state machine design
 
projection of solid
projection of solidprojection of solid
projection of solid
 
basic electronics, Transmission lines, wave guides And Antenna fundamental
basic electronics, Transmission lines, wave guides And Antenna fundamentalbasic electronics, Transmission lines, wave guides And Antenna fundamental
basic electronics, Transmission lines, wave guides And Antenna fundamental
 
linear equations
linear equationslinear equations
linear equations
 
Radioactive pollution
Radioactive pollutionRadioactive pollution
Radioactive pollution
 
Perfect Bookreview - you can win
Perfect Bookreview - you can winPerfect Bookreview - you can win
Perfect Bookreview - you can win
 
mechanical engineering transmission of motion and power
 mechanical engineering transmission of motion and power mechanical engineering transmission of motion and power
mechanical engineering transmission of motion and power
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

basics of virtual memory

  • 1.
  • 2. 2  Recall: memory allocation with variable partitions requires mapping logical addresses to physical addresses  Virtual memory achieves a complete separation of logical and physical address- spaces  Typically a virtual address is 32 bits, this allows a process to have 4GB of virtual memory  Physical memory is much smaller than this, and varies from machine to machine  Virtual address spaces of different processes are distinct  Structuring of virtual memory  Paging: Divide the address space into fixed-size pages  Segmentation: Divide the address space into variable-size segments (corresponding to logical units)
  • 5.  Benefits of Virtual Memory ::  Less I/O needed to load / swap a process.  Degree of multiprogramming can be increased.  A program’s logical address space can be larger than physical memory.
  • 6.  How do we know if a page is in main memory or not?  With each page table entry, a valid–invalid bit is associated (1  legal/in-memory , 0  not-in-memory)  During address translation, if valid–invalid bit in page table entry is 0  page fault trap 1 1 1 1 0 0 0  Frame # valid-invalid bit page table
  • 7. Dirty bit in Page table
  • 8.  Hardware traps to kernel on page fault  CPU registers of current process are saved  OS determines which virtual page needed  OS checks validity of address, protection status  Check if there is a free frame, else invoke page replacement policy to select a frame  If selected frame is dirty, write it to disk  When page frame is clean, schedule I/O to read in page  Page table updated  Process causing fault rescheduled  Instruction causing fault reinstated  Registers restored, and program continues execution
  • 9. GMU – CS 571 Steps in Handling a Page Fault
  • 10. GMU – CS 571 Impact of Page Faults  Each page fault affects the system performance negatively  The process experiencing the page fault will not be able to continue until the missing page is brought to the main memory  The process will be blocked (moved to the waiting state) so its data (registers, etc.) must be saved.  Dealing with the page fault involves disk I/O  Increased demand to the disk drive  Increased waiting time for process experiencing the page fault
  • 11. Page-Fault Frequency Scheme  Establish “acceptable” page-fault rate.  If actual rate too low, process loses frame.  If actual rate too high, process gains frame.
  • 12. 12  To avoid thrashing (i.e. too many page faults), a process needs “enough” pages in the memory  Memory accesses by a program are not spread all over its virtual memory randomly, but show a pattern  E.g. while executing a procedure, a program is accessing the page that contains the code of the procedure, the local variables, and global vars.  This is called locality of reference.  How to exploit locality?  PrePaging : when a process is brought into memory by the swapper, a few pages are loaded in a priory (note: demand paging means that a page is brought in only when needed)  Working set: Try to keep currently used pages in memory
  • 13. 13  The phenomenon that programs actually use only a limited set of pages during any particular time period of execution.  This set of pages is called the locality of the program during that time.  Ex. Program phase diagram virtual address -------------------------- 5 | | x | x | | -------------------------- 4 | | x | x | | -------------------------- segments 3 | x | x | x | x | -------------------------- 2 x | x | | x | x | -------------------------- 1 x | x | | | | 1 2 3 4 5 virtual phases time
  • 14. 14  Working set of a process at time t is the set of pages referenced over last k accesses (here, k is a parameter)  Goal of working set based algorithms: keep the working set in memory, and replace pages not in the working set  Maintaining the precise working set not feasible (since we don’t want to update data structures upon every memory access)  Compromise: Redefine working set to be the set of pages referenced over last m clock cycles  Recall: clock interrupt happens every 40 ms and OS can check if the page has been referenced during the last cycle (R=1)
  • 15. 15  The working set of a process is the set of all pages accessed by the process within some fixed time window. Locality of reference means that a process's working set is usually small compared to the total number of pages it possesses.  A program's working set at the k-th reference with window size h is defined to be W(k,h) = { i  N | page i appears among rk-h+1 … rk }  The working set at time t is W(t,h) = W(k,h) where time(rk)  t < t(rk+1)  Ex. h=4  w = 1 2 3 4 1 2 5 1 2 5 3 2 | | | | | | | | | | | | {1} | | | | | | | | | | | {1,2}| {1,2,3,4} | {1,2,5} | | {1,2,3} {1,2,4,5} {1,2,3,5}
  • 16.   = working-set window = a fixed number of page references Example: 10,000 instruction  WSSi (working set of Process Pi) = total number of pages referenced in the most recent  (varies in time)  if  too small will not encompass entire locality.  if  too large will encompass several localities.  if  =   will encompass entire program.  D =  WSSi  total demand frames  if D > m  Thrashing  Policy if D > m, then suspend one of the processes.
  • 17. Working Sets and Page Fault Rates