SlideShare a Scribd company logo
VIRTUAL MEMORY

BY,
SHASHANK SHETTY
WHAT IS VIRTUAL MEMORY???
 Entire process in memory before it can be executed.
 Virtual memory is a technique that allows execution
of the processes that are not completely in memory.

 Program can be larger than physical memory.
Virtual memory – separation of user logical memory
from physical memory.
 Memory storage limitation can be freed.
Virtual memory is not easy to implement.
BACKGROUND
Only part of the program needs to be in memory for
execution.
The need of instruction in physical memory to be
executed seems to be necessary & reasonable, but its
unfortunate.
The entire program is not needed.
 Executing the program partially in memory has
benefits:
 Program would no longer be constrained by the
amount of physical memory that is available.
 If programs could take less physical memory, more
programs could be run at the same time.
Virtual Memory That is Larger Than Physical Memory


 Thus, running a program that is not entirely
in memory would benefit both the system and the
user.
 Virtual memory can be implemented via:
• Demand paging
• Demand segmentation
Virtual-address Space
The virtual
address space of a
process refers to
the logical (or
virtual) view
of how a process
is stored in
memory.
Shared Library Using Virtual Memory
 In addition to separating logical memory from physical memory,
virtual memory also allows files and memory to be shared by
two or more processes through page sharing. This leads to the
following benefits:
System libraries can be shared by several processes through
mapping of the shared object into a virtual address space.
Virtual memory enables processes to share memory.

Virtual memory can allow pages to be shared during process
creation with the forkO system call, thus speeding up process
creation.
DEMAND PAGING
 Consider how an executable program might be
loaded from disk to memory.
 One option, load the entire program in physical
memory.
Ex: User selection program
 Second approach, load the pages only as they
needed ( DEMAND PAGING).
 A demand paging system is similar to the paging
system with swapping.
• Bring a page into memory only when it is needed
– Less I/O needed
– Less memory needed
– Faster response
– More users
• Page is needed  reference to it
– invalid reference  abort
– not-in-memory  bring to memory
Transfer of a Paged Memory to Contiguous Disk Space
Valid-Invalid Bit
• With each page table entry a valid–invalid bit is associated
(1  in-memory, 0  not-in-memory)
• Initially valid–invalid bit is set to 0 on all entries
• Example of a page table snapshot:
Frame #

valid-invalid bit

1
1
1
1
0

0
0
page table

• During address translation, if valid–invalid bit in page table entry is
0  page fault
Page Table When Some Pages Are Not in Main
Memory
Page Fault
• What happens if the process tries to access a page and
that page was not brought into memory??????
• OS looks at another table to decide:
– Invalid reference  abort.
– Just not in memory.
• Get empty frame.
• Swap page into frame.
• Reset tables, validation bit = 1.
• Restart instruction: Least Recently Used
– block move

– auto increment/decrement location
Steps in Handling a Page Fault
 The hardware to support Demand paging:
 Page Table
 Secondary Memory
What happens if there is no free frame?
• Page replacement – find some page in
memory, but not really in use, swap it out
– algorithm
– performance – want an algorithm which
will result in minimum number of page
faults
• Same page may be brought into memory
several times
Performance of Demand Paging
• Page Fault Rate 0  p  1.0
– if p = 0 no page faults
– if p = 1, every reference is a fault

• Effective Access Time (EAT)
EAT = (1 – p) x memory access
+ p (page fault overhead
+ [swap page out ]
+ swap page in
+ restart overhead)
Demand Paging Example
If we take an average page-fault service time of
8 milliseconds and a memory-access time of 200
nanoseconds, then the effective access time in
nanoseconds is
Copy-on-Write
• Copy-on-Write (COW) allows both parent and
child processes to initially share the same pages
in memory
If either process modifies a shared page, only
then is the page copied
• COW allows more efficient process creation as
only modified pages are copied

• Free pages are allocated from a pool of zeroedout pages
Virtual memory

More Related Content

What's hot

8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
Dr. Loganathan R
 
Swapping | Computer Science
Swapping | Computer ScienceSwapping | Computer Science
Swapping | Computer Science
Transweb Global Inc
 
Demand paging
Demand pagingDemand paging
Demand paging
SwaroopSorte
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
sangrampatil81
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAnuj Modi
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithmsPiyush Rochwani
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
sanjana mun
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43myrajendra
 
Operating Systems: Device Management
Operating Systems: Device ManagementOperating Systems: Device Management
Operating Systems: Device Management
Damian T. Gordon
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
sgpraju
 
Operating system paging and segmentation
Operating system paging and segmentationOperating system paging and segmentation
Operating system paging and segmentation
hamza haseeb
 
Memory Management
Memory ManagementMemory Management
Memory Management
DEDE IRYAWAN
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
Kumar Pritam
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
Shashank Asthana
 
Virtual memory presentation
Virtual memory presentationVirtual memory presentation
Virtual memory presentation
Ranjeet Kumar
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
Sandesh Jonchhe
 

What's hot (20)

8 memory management strategies
8 memory management strategies8 memory management strategies
8 memory management strategies
 
Swapping | Computer Science
Swapping | Computer ScienceSwapping | Computer Science
Swapping | Computer Science
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Memory management
Memory managementMemory management
Memory management
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 
Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
 
Operating Systems: Device Management
Operating Systems: Device ManagementOperating Systems: Device Management
Operating Systems: Device Management
 
Os Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual MemoryOs Swapping, Paging, Segmentation and Virtual Memory
Os Swapping, Paging, Segmentation and Virtual Memory
 
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
 
Virtual memory
Virtual memory Virtual memory
Virtual memory
 
Memory Management in OS
Memory Management in OSMemory Management in OS
Memory Management in OS
 
Operating system Memory management
Operating system Memory management Operating system Memory management
Operating system Memory management
 
Virtual memory presentation
Virtual memory presentationVirtual memory presentation
Virtual memory presentation
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
 

Similar to Virtual memory

Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Management
Rahul Jamwal
 
Virtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdfVirtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdf
Harika Pudugosula
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managment
Santu Kumar
 
Virtual memory - Demand Paging
Virtual memory - Demand PagingVirtual memory - Demand Paging
Virtual memory - Demand Paging
jeyaperumal
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
lodhran-hayat
 
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
Rai University
 
virtual memory
virtual memoryvirtual memory
virtual memory
sangrampatil81
 
Virtual Memory.pdf
Virtual Memory.pdfVirtual Memory.pdf
Virtual Memory.pdf
SujanTimalsina5
 
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
ry54321288
 
OS Presentation 2023.pptx
OS Presentation 2023.pptxOS Presentation 2023.pptx
OS Presentation 2023.pptx
ShayanAli68
 
CH09.pdf
CH09.pdfCH09.pdf
CH09.pdf
ImranKhan880955
 
Adobe Scan 06-Jan-2023.pdf demand paging document
Adobe Scan 06-Jan-2023.pdf demand paging documentAdobe Scan 06-Jan-2023.pdf demand paging document
Adobe Scan 06-Jan-2023.pdf demand paging document
AllyKhan2
 
Operating system 37 demand paging
Operating system 37 demand pagingOperating system 37 demand paging
Operating system 37 demand paging
Vaibhav Khanna
 
CSI-503 - 9. Virtual Memory
CSI-503 - 9. Virtual MemoryCSI-503 - 9. Virtual Memory
CSI-503 - 9. Virtual Memory
ghayour abbas
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
Kalai Selvi
 
Lecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptxLecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptx
Amanuelmergia
 
Module4
Module4Module4
Module4
dilshad begum
 
Power Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.pptPower Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.ppt
RahulRaj395610
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
vampugani
 

Similar to Virtual memory (20)

Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Management
 
Virtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdfVirtual Memory Management Part - I.pdf
Virtual Memory Management Part - I.pdf
 
Virtual memory managment
Virtual memory managmentVirtual memory managment
Virtual memory managment
 
Virtual memory - Demand Paging
Virtual memory - Demand PagingVirtual memory - Demand Paging
Virtual memory - Demand Paging
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
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
 
virtual memory
virtual memoryvirtual memory
virtual memory
 
Virtual Memory.pdf
Virtual Memory.pdfVirtual Memory.pdf
Virtual Memory.pdf
 
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
 
OS Presentation 2023.pptx
OS Presentation 2023.pptxOS Presentation 2023.pptx
OS Presentation 2023.pptx
 
CH09.pdf
CH09.pdfCH09.pdf
CH09.pdf
 
Adobe Scan 06-Jan-2023.pdf demand paging document
Adobe Scan 06-Jan-2023.pdf demand paging documentAdobe Scan 06-Jan-2023.pdf demand paging document
Adobe Scan 06-Jan-2023.pdf demand paging document
 
Operating system 37 demand paging
Operating system 37 demand pagingOperating system 37 demand paging
Operating system 37 demand paging
 
CSI-503 - 9. Virtual Memory
CSI-503 - 9. Virtual MemoryCSI-503 - 9. Virtual Memory
CSI-503 - 9. Virtual Memory
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
 
Lecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptxLecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptx
 
Module4
Module4Module4
Module4
 
Power Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.pptPower Point Presentation on Virtual Memory.ppt
Power Point Presentation on Virtual Memory.ppt
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Virtual Memory
Virtual MemoryVirtual Memory
Virtual Memory
 

Recently uploaded

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 

Recently uploaded (20)

"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 

Virtual memory

  • 2. WHAT IS VIRTUAL MEMORY???  Entire process in memory before it can be executed.  Virtual memory is a technique that allows execution of the processes that are not completely in memory.  Program can be larger than physical memory. Virtual memory – separation of user logical memory from physical memory.  Memory storage limitation can be freed. Virtual memory is not easy to implement.
  • 3. BACKGROUND Only part of the program needs to be in memory for execution. The need of instruction in physical memory to be executed seems to be necessary & reasonable, but its unfortunate. The entire program is not needed.  Executing the program partially in memory has benefits:  Program would no longer be constrained by the amount of physical memory that is available.  If programs could take less physical memory, more programs could be run at the same time.
  • 4. Virtual Memory That is Larger Than Physical Memory 
  • 5.  Thus, running a program that is not entirely in memory would benefit both the system and the user.  Virtual memory can be implemented via: • Demand paging • Demand segmentation
  • 6. Virtual-address Space The virtual address space of a process refers to the logical (or virtual) view of how a process is stored in memory.
  • 7. Shared Library Using Virtual Memory
  • 8.  In addition to separating logical memory from physical memory, virtual memory also allows files and memory to be shared by two or more processes through page sharing. This leads to the following benefits: System libraries can be shared by several processes through mapping of the shared object into a virtual address space. Virtual memory enables processes to share memory. Virtual memory can allow pages to be shared during process creation with the forkO system call, thus speeding up process creation.
  • 9. DEMAND PAGING  Consider how an executable program might be loaded from disk to memory.  One option, load the entire program in physical memory. Ex: User selection program  Second approach, load the pages only as they needed ( DEMAND PAGING).  A demand paging system is similar to the paging system with swapping.
  • 10. • Bring a page into memory only when it is needed – Less I/O needed – Less memory needed – Faster response – More users • Page is needed  reference to it – invalid reference  abort – not-in-memory  bring to memory
  • 11. Transfer of a Paged Memory to Contiguous Disk Space
  • 12. Valid-Invalid Bit • With each page table entry a valid–invalid bit is associated (1  in-memory, 0  not-in-memory) • Initially valid–invalid bit is set to 0 on all entries • Example of a page table snapshot: Frame # valid-invalid bit 1 1 1 1 0  0 0 page table • During address translation, if valid–invalid bit in page table entry is 0  page fault
  • 13. Page Table When Some Pages Are Not in Main Memory
  • 14. Page Fault • What happens if the process tries to access a page and that page was not brought into memory?????? • OS looks at another table to decide: – Invalid reference  abort. – Just not in memory. • Get empty frame. • Swap page into frame. • Reset tables, validation bit = 1. • Restart instruction: Least Recently Used – block move – auto increment/decrement location
  • 15. Steps in Handling a Page Fault
  • 16.  The hardware to support Demand paging:  Page Table  Secondary Memory
  • 17. What happens if there is no free frame? • Page replacement – find some page in memory, but not really in use, swap it out – algorithm – performance – want an algorithm which will result in minimum number of page faults • Same page may be brought into memory several times
  • 18. Performance of Demand Paging • Page Fault Rate 0  p  1.0 – if p = 0 no page faults – if p = 1, every reference is a fault • Effective Access Time (EAT) EAT = (1 – p) x memory access + p (page fault overhead + [swap page out ] + swap page in + restart overhead)
  • 19. Demand Paging Example If we take an average page-fault service time of 8 milliseconds and a memory-access time of 200 nanoseconds, then the effective access time in nanoseconds is
  • 20. Copy-on-Write • Copy-on-Write (COW) allows both parent and child processes to initially share the same pages in memory If either process modifies a shared page, only then is the page copied • COW allows more efficient process creation as only modified pages are copied • Free pages are allocated from a pool of zeroedout pages