SlideShare a Scribd company logo
COURSE NAME : OPERATING SYSTEM
COURSE CODE : 381CCS-3
CHAPTER 7 : VIRTUAL MEMORY
SUBJECT COORDINATOR: DR. ANAND DEVADURAI
SUBJECT TEACHER: MRS. MARIYAM AYSHA BIVI
DEPARTMENT OF COMPUTER SCIENCE
KING KHALID UNIVERSITY
ABHA, KSA.
REFERENCE DETAIL FOR CHAPTER 6
Topic Text Reference Chapter No. Page No
Virtual Memory
“Operating System
Concepts”, 10th Edition,
Abraham SilberSchatz,
Peter Baer Galvin,
Greg Gagne, Wiley, 2018
Chapter 10
389-399
401-412
2
 Background 399 (501 to 511)
 Demand Paging 10.2
 Basic Concept
 Free-Frame list
 Performance of Demand paging
 Page Replacement 10.4
 Basic Page Replacement (401 - 412 : 513 to 524)
 FIFO Page Replacement
 Optimal Page Replacement
 LRU Page Replacement
 Counting-Based Page Replacement
CHAPTER 7 : VIRTUAL MEMORY
7.1 BACKGROUND
3
 Code needs to be in memory to execute, but entire program rarely used
• Error code, unusual routines, large data structures
 Entire program code not needed at same time
 Virtual memory
• It is a scheme that allows a process to execute while it is only partially
in memory,
 Advantages of Virtual memory
• Program no longer constrained by limits of physical memory
• Logical address space will be larger than physical address space Process
size can exceed the physical memory size
• Less I/O needed
• Less memory needed
• Faster response
• More programs running concurrently
• Increased CPU utilization and throughput
 Disadvantages of Virtual memory
• Many page faults when a process is started but should decrease as
more pages are brought in
7.1 BACKGROUND(CONT…)
4
 Virtual address space: logical/virtual) view of how process is stored in memory
 start at address 0, contiguous addresses until end of space
 Physical memory is organized in page frames, assigned to a process may not be
contiguous. Memory Management Unit must map logical to physical
 The heap grow upward used for dynamic memory allocation and the stack grow
downward in memory through successive function calls.
 Virtual address spaces that include holes are known as sparse address spaces..
Figure 7.1 Virtual address space
of a process in memory Figure 7.2 Shared library using virtual memory.
7.2 DEMAND PAGING
5
 Load pages only as they are needed is known as Demand Paging, commonly
used in virtual memory systems.
7.2.1 BASIC CONCEPT
 With each page table entry a valid–invalid bit is associated
(v  in-memory – memory resident, i  not-in-memory)
 Initially valid–invalid bit is set to i on all entries
 During MMU address translation, if valid–invalid bit in is i  page fault
Figure 7.3 Page table when some pages are not in main memory.
6
STEPS IN HANDLING A PAGE FAULT
1. If there is a reference to a page, first reference to that page will trap to operating
system Page fault
2. Operating system looks at another table to decide:
Invalid reference  abort, Just not in memory
3. Find free frame
4. Swap page into frame via scheduled disk operation
5. Reset tables to indicate page now in memory, Set validation bit = v
6. Restart the instruction that caused the page fault
Figure 7.3 Page table when some pages are not in main memory.
7.2.2 FREE-FRAME LIST
7
 When a page fault occurs, the operating system must bring the desired page from
secondary storage into main memory.
 Most operating systems maintain a free-frame list -- a pool of free frames for
satisfying such requests.
 Operating system typically allocate free frames using a technique known as zero-
fill-on-demand -- the content of the frames zeroed-out before being allocated.
 When a system starts up, all available memory is placed on the free-frame list.
7.2.2 PERFORMANCE OF DEMAND PAGING
 Page Fault Rate 0  p  1,if p = 0 no page faults, if p = 1, every reference is a fault
 Effective Access Time (EAT) = (1 − p) × ma + p × page fault time.
 Example: If one access out of 1,000 causes a page fault, Memory access time =
200 nanoseconds, Average page-fault service time = 8 milliseconds Compute EAT
EAT = (1 – p) x 200 + p (8 milliseconds)
= (1 – p) x 200 + p x 8,000,000
= 200 – 200 p + 8,000,000 p =
= 200 + p x 7,999,800
= 200 + (1/1000) x 7,999,800 = 8,199.8 milli Seconds
EAT = 8,199.8 /1000 = 8.2 microseconds.
7.3 PAGE REPLACEMENT
8
 Prevent over-allocation of memory by modifying page-fault service routine to
include page replacement
 Use modify (dirty) bit to reduce overhead of page transfers – only modified
pages are written to disk
7.3.1 BASIC PAGE REPLACEMENT
1. Find the location of the desired page on disk
2. Find a free frame:
- If there is a free frame, use it
- If no free frame, use a page replacement
algorithm to select a victim frame
- Write victim frame to disk if dirty
3. Bring the desired page into the (newly) free
frame; update the page and frame tables
4. Continue the process by restarting the
instruction that caused the trap
7.3.2 FIFO PAGE REPLACEMENT ALGORITHM
9
 When a page must be replaced, the oldest page is chosen.
 Reference string: 7,0,1,2,0,3,0,4,2,3,0,3,0,3,2,1,2,0,1,7,0,1
 3 frames (3 pages can be in memory at a time per process)
 Page Fault = 15
 Can vary by reference string: consider 1,2,3,4,1,2,5,1,2,3,4,5
• Adding more frames can cause more page faults!
 Belady’s Anomaly
 How to track ages of pages?
• Just use a FIFO queue
7.3.3 OPTIMAL PAGE REPLACEMENT ALGORITHM
1
0
 Replace page that will not be used for longest period of time
• 9 is optimal for the example
 How do you know this?
• Can’t read the future
 Used for measuring how well your algorithm performs
 Page Fault = 9
7.3.4 LEAST RECENTLY USED (LRU) ALGORITHM
11
 Replace page that has not been used in the most amount of time
 Associate time of last use with each page
 Page Fault = 12, Better than FIFO but worse than OPT
 Generally good algorithm and frequently used
7.3.5 COUNTING BASED PAGE REPLACEMENT ALGORITHM
 Lease Frequently Used (LFU) Algorithm:
• Replaces page with smallest count
 Most Frequently Used (MFU) Algorithm:
• Based on the argument that the page with the smallest count was
probably just brought in and has yet to be used

More Related Content

What's hot

Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43myrajendra
 
basics of virtual memory
basics of virtual memorybasics of virtual memory
basics of virtual memory
Adarsh Patel
 
Postgresql Database Administration Basic - Day1
Postgresql  Database Administration Basic  - Day1Postgresql  Database Administration Basic  - Day1
Postgresql Database Administration Basic - Day1
PoguttuezhiniVP
 
Forecasting database performance
Forecasting database performanceForecasting database performance
Forecasting database performance
Shenglin Du
 
Mysql database basic user guide
Mysql database basic user guideMysql database basic user guide
Mysql database basic user guide
PoguttuezhiniVP
 
Neptune Distributed Data System
Neptune Distributed Data SystemNeptune Distributed Data System
Neptune Distributed Data System
Hyoungjun Kim
 
An Empirical Study of Hot/Cold Data Separation Policies in Solid State Drives...
An Empirical Study of Hot/Cold Data Separation Policies in Solid State Drives...An Empirical Study of Hot/Cold Data Separation Policies in Solid State Drives...
An Empirical Study of Hot/Cold Data Separation Policies in Solid State Drives...
leitia07
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryMohd Arif
 
MySQL database replication
MySQL database replicationMySQL database replication
MySQL database replication
PoguttuezhiniVP
 
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
Equnix Business Solutions
 
Virtual memory ,Allocaton of frame & Trashing
Virtual memory  ,Allocaton of frame & TrashingVirtual memory  ,Allocaton of frame & Trashing
Virtual memory ,Allocaton of frame & Trashing
COMSATS Institute of Information Technology
 
PGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar Ahmed
PGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar AhmedPGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar Ahmed
PGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar Ahmed
Equnix Business Solutions
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithm
Muhammad Mansoor Ul Haq
 
Tek tutorial
Tek tutorialTek tutorial
Tek tutorial
Ligaya Turmelle
 
I/O buffering & disk scheduling
I/O buffering & disk schedulingI/O buffering & disk scheduling
I/O buffering & disk scheduling
Rushabh Shah
 
Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree
Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree
Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree
Ashnikbiz
 
Memory Hierarchy Design, Basics, Cache Optimization, Address Translation
Memory Hierarchy Design, Basics, Cache Optimization, Address TranslationMemory Hierarchy Design, Basics, Cache Optimization, Address Translation
Memory Hierarchy Design, Basics, Cache Optimization, Address Translation
Farwa Ansari
 
Project Presentation Final
Project Presentation FinalProject Presentation Final
Project Presentation FinalDhritiman Halder
 
W1.1 i os in database
W1.1   i os in databaseW1.1   i os in database
W1.1 i os in database
gafurov_x
 

What's hot (20)

Thrashing allocation frames.43
Thrashing allocation frames.43Thrashing allocation frames.43
Thrashing allocation frames.43
 
basics of virtual memory
basics of virtual memorybasics of virtual memory
basics of virtual memory
 
Postgresql Database Administration Basic - Day1
Postgresql  Database Administration Basic  - Day1Postgresql  Database Administration Basic  - Day1
Postgresql Database Administration Basic - Day1
 
Forecasting database performance
Forecasting database performanceForecasting database performance
Forecasting database performance
 
Mysql database basic user guide
Mysql database basic user guideMysql database basic user guide
Mysql database basic user guide
 
Neptune Distributed Data System
Neptune Distributed Data SystemNeptune Distributed Data System
Neptune Distributed Data System
 
An Empirical Study of Hot/Cold Data Separation Policies in Solid State Drives...
An Empirical Study of Hot/Cold Data Separation Policies in Solid State Drives...An Empirical Study of Hot/Cold Data Separation Policies in Solid State Drives...
An Empirical Study of Hot/Cold Data Separation Policies in Solid State Drives...
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
MySQL database replication
MySQL database replicationMySQL database replication
MySQL database replication
 
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
PGConf.ASIA 2019 Bali - Building PostgreSQL as a Service with Kubernetes - Ta...
 
Virtual memory ,Allocaton of frame & Trashing
Virtual memory  ,Allocaton of frame & TrashingVirtual memory  ,Allocaton of frame & Trashing
Virtual memory ,Allocaton of frame & Trashing
 
PGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar Ahmed
PGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar AhmedPGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar Ahmed
PGConf.ASIA 2019 Bali - Tune Your LInux Box, Not Just PostgreSQL - Ibrar Ahmed
 
Virtual memory and page replacement algorithm
Virtual memory and page replacement algorithmVirtual memory and page replacement algorithm
Virtual memory and page replacement algorithm
 
Tek tutorial
Tek tutorialTek tutorial
Tek tutorial
 
Virtual memory
Virtual memory Virtual memory
Virtual memory
 
I/O buffering & disk scheduling
I/O buffering & disk schedulingI/O buffering & disk scheduling
I/O buffering & disk scheduling
 
Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree
Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree
Countdown to PostgreSQL v9.5 - Foriegn Tables can be part of Inheritance Tree
 
Memory Hierarchy Design, Basics, Cache Optimization, Address Translation
Memory Hierarchy Design, Basics, Cache Optimization, Address TranslationMemory Hierarchy Design, Basics, Cache Optimization, Address Translation
Memory Hierarchy Design, Basics, Cache Optimization, Address Translation
 
Project Presentation Final
Project Presentation FinalProject Presentation Final
Project Presentation Final
 
W1.1 i os in database
W1.1   i os in databaseW1.1   i os in database
W1.1 i os in database
 

Similar to 381 ccs chapter7_updated(1)

CH09.pdf
CH09.pdfCH09.pdf
CH09.pdf
ImranKhan880955
 
Module4
Module4Module4
Module4
dilshad begum
 
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
 
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
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
Wayne Jones Jnr
 
Distributed Operating System_3
Distributed Operating System_3Distributed Operating System_3
Distributed Operating System_3
Dr Sandeep Kumar Poonia
 
Mem mgt
Mem mgtMem mgt
Ch10 OS
Ch10 OSCh10 OS
Ch10 OSC.U
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
Rashmi Bhat
 
virtual memory
virtual memoryvirtual memory
virtual memory
Abeer Naskar
 
Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858
marangburu42
 
Virtual memoryfinal
Virtual memoryfinalVirtual memoryfinal
Virtual memoryfinal
marangburu42
 
Virtual memory pre-final-formatting
Virtual memory pre-final-formattingVirtual memory pre-final-formatting
Virtual memory pre-final-formatting
marangburu42
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Management
Rahul Jamwal
 
Virtualmemorypre final-formatting-161019022904
Virtualmemorypre final-formatting-161019022904Virtualmemorypre final-formatting-161019022904
Virtualmemorypre final-formatting-161019022904
marangburu42
 
Lecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptxLecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptx
Amanuelmergia
 
Virtual memory - Demand Paging
Virtual memory - Demand PagingVirtual memory - Demand Paging
Virtual memory - Demand Paging
jeyaperumal
 

Similar to 381 ccs chapter7_updated(1) (20)

CH09.pdf
CH09.pdfCH09.pdf
CH09.pdf
 
Module4
Module4Module4
Module4
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
 
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
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 
Distributed Operating System_3
Distributed Operating System_3Distributed Operating System_3
Distributed Operating System_3
 
Mem mgt
Mem mgtMem mgt
Mem mgt
 
OS_Ch10
OS_Ch10OS_Ch10
OS_Ch10
 
Ch10 OS
Ch10 OSCh10 OS
Ch10 OS
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
virtual memory
virtual memoryvirtual memory
virtual memory
 
Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858
 
Virtual memoryfinal
Virtual memoryfinalVirtual memoryfinal
Virtual memoryfinal
 
Virtual memory pre-final-formatting
Virtual memory pre-final-formattingVirtual memory pre-final-formatting
Virtual memory pre-final-formatting
 
Virtual Memory Management
Virtual Memory ManagementVirtual Memory Management
Virtual Memory Management
 
Virtualmemorypre final-formatting-161019022904
Virtualmemorypre final-formatting-161019022904Virtualmemorypre final-formatting-161019022904
Virtualmemorypre final-formatting-161019022904
 
Ch09
Ch09Ch09
Ch09
 
Lecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptxLecture 8- Virtual Memory Final.pptx
Lecture 8- Virtual Memory Final.pptx
 
Virtual memory - Demand Paging
Virtual memory - Demand PagingVirtual memory - Demand Paging
Virtual memory - Demand Paging
 
Ch8
Ch8Ch8
Ch8
 

Recently uploaded

Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 

Recently uploaded (20)

Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang,  ICLR 2024, MLILAB, KAIST AI.pdfJ.Yang,  ICLR 2024, MLILAB, KAIST AI.pdf
J.Yang, ICLR 2024, MLILAB, KAIST AI.pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 

381 ccs chapter7_updated(1)

  • 1. COURSE NAME : OPERATING SYSTEM COURSE CODE : 381CCS-3 CHAPTER 7 : VIRTUAL MEMORY SUBJECT COORDINATOR: DR. ANAND DEVADURAI SUBJECT TEACHER: MRS. MARIYAM AYSHA BIVI DEPARTMENT OF COMPUTER SCIENCE KING KHALID UNIVERSITY ABHA, KSA. REFERENCE DETAIL FOR CHAPTER 6 Topic Text Reference Chapter No. Page No Virtual Memory “Operating System Concepts”, 10th Edition, Abraham SilberSchatz, Peter Baer Galvin, Greg Gagne, Wiley, 2018 Chapter 10 389-399 401-412
  • 2. 2  Background 399 (501 to 511)  Demand Paging 10.2  Basic Concept  Free-Frame list  Performance of Demand paging  Page Replacement 10.4  Basic Page Replacement (401 - 412 : 513 to 524)  FIFO Page Replacement  Optimal Page Replacement  LRU Page Replacement  Counting-Based Page Replacement CHAPTER 7 : VIRTUAL MEMORY
  • 3. 7.1 BACKGROUND 3  Code needs to be in memory to execute, but entire program rarely used • Error code, unusual routines, large data structures  Entire program code not needed at same time  Virtual memory • It is a scheme that allows a process to execute while it is only partially in memory,  Advantages of Virtual memory • Program no longer constrained by limits of physical memory • Logical address space will be larger than physical address space Process size can exceed the physical memory size • Less I/O needed • Less memory needed • Faster response • More programs running concurrently • Increased CPU utilization and throughput  Disadvantages of Virtual memory • Many page faults when a process is started but should decrease as more pages are brought in
  • 4. 7.1 BACKGROUND(CONT…) 4  Virtual address space: logical/virtual) view of how process is stored in memory  start at address 0, contiguous addresses until end of space  Physical memory is organized in page frames, assigned to a process may not be contiguous. Memory Management Unit must map logical to physical  The heap grow upward used for dynamic memory allocation and the stack grow downward in memory through successive function calls.  Virtual address spaces that include holes are known as sparse address spaces.. Figure 7.1 Virtual address space of a process in memory Figure 7.2 Shared library using virtual memory.
  • 5. 7.2 DEMAND PAGING 5  Load pages only as they are needed is known as Demand Paging, commonly used in virtual memory systems. 7.2.1 BASIC CONCEPT  With each page table entry a valid–invalid bit is associated (v  in-memory – memory resident, i  not-in-memory)  Initially valid–invalid bit is set to i on all entries  During MMU address translation, if valid–invalid bit in is i  page fault Figure 7.3 Page table when some pages are not in main memory.
  • 6. 6 STEPS IN HANDLING A PAGE FAULT 1. If there is a reference to a page, first reference to that page will trap to operating system Page fault 2. Operating system looks at another table to decide: Invalid reference  abort, Just not in memory 3. Find free frame 4. Swap page into frame via scheduled disk operation 5. Reset tables to indicate page now in memory, Set validation bit = v 6. Restart the instruction that caused the page fault Figure 7.3 Page table when some pages are not in main memory.
  • 7. 7.2.2 FREE-FRAME LIST 7  When a page fault occurs, the operating system must bring the desired page from secondary storage into main memory.  Most operating systems maintain a free-frame list -- a pool of free frames for satisfying such requests.  Operating system typically allocate free frames using a technique known as zero- fill-on-demand -- the content of the frames zeroed-out before being allocated.  When a system starts up, all available memory is placed on the free-frame list. 7.2.2 PERFORMANCE OF DEMAND PAGING  Page Fault Rate 0  p  1,if p = 0 no page faults, if p = 1, every reference is a fault  Effective Access Time (EAT) = (1 − p) × ma + p × page fault time.  Example: If one access out of 1,000 causes a page fault, Memory access time = 200 nanoseconds, Average page-fault service time = 8 milliseconds Compute EAT EAT = (1 – p) x 200 + p (8 milliseconds) = (1 – p) x 200 + p x 8,000,000 = 200 – 200 p + 8,000,000 p = = 200 + p x 7,999,800 = 200 + (1/1000) x 7,999,800 = 8,199.8 milli Seconds EAT = 8,199.8 /1000 = 8.2 microseconds.
  • 8. 7.3 PAGE REPLACEMENT 8  Prevent over-allocation of memory by modifying page-fault service routine to include page replacement  Use modify (dirty) bit to reduce overhead of page transfers – only modified pages are written to disk 7.3.1 BASIC PAGE REPLACEMENT 1. Find the location of the desired page on disk 2. Find a free frame: - If there is a free frame, use it - If no free frame, use a page replacement algorithm to select a victim frame - Write victim frame to disk if dirty 3. Bring the desired page into the (newly) free frame; update the page and frame tables 4. Continue the process by restarting the instruction that caused the trap
  • 9. 7.3.2 FIFO PAGE REPLACEMENT ALGORITHM 9  When a page must be replaced, the oldest page is chosen.  Reference string: 7,0,1,2,0,3,0,4,2,3,0,3,0,3,2,1,2,0,1,7,0,1  3 frames (3 pages can be in memory at a time per process)  Page Fault = 15  Can vary by reference string: consider 1,2,3,4,1,2,5,1,2,3,4,5 • Adding more frames can cause more page faults!  Belady’s Anomaly  How to track ages of pages? • Just use a FIFO queue
  • 10. 7.3.3 OPTIMAL PAGE REPLACEMENT ALGORITHM 1 0  Replace page that will not be used for longest period of time • 9 is optimal for the example  How do you know this? • Can’t read the future  Used for measuring how well your algorithm performs  Page Fault = 9
  • 11. 7.3.4 LEAST RECENTLY USED (LRU) ALGORITHM 11  Replace page that has not been used in the most amount of time  Associate time of last use with each page  Page Fault = 12, Better than FIFO but worse than OPT  Generally good algorithm and frequently used 7.3.5 COUNTING BASED PAGE REPLACEMENT ALGORITHM  Lease Frequently Used (LFU) Algorithm: • Replaces page with smallest count  Most Frequently Used (MFU) Algorithm: • Based on the argument that the page with the smallest count was probably just brought in and has yet to be used