SlideShare a Scribd company logo
1 of 19
Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Page Replacement
Algorithms
10.2 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
What Happens if There is no Free Frame?
 Issues and Policies:
 What if all frames are used up by process pages?
 What if there is a demand from the kernel, I/O buffers, etc.
 How much to allocate to each process (what is the min and max)?
 Page Replacement
 Find some page in memory, but not really in use, page it out
 If no frame is free, we find one that is not currently being used and free it
 Algorithm – terminate? swap out? replace the page?
 Performance – want an algorithm which will result in minimum number of page faults
 What if the same page may be brought into memory several times
 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
 Page replacement completes separation between logical memory and physical memory
– large virtual memory can be provided on a smaller physical memory
10.3 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Need For Page Replacement
10.4 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
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 there is 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
 Note:
 Potentially 2 page transfers for page fault
 increasing EAT
10.5 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Page Replacement
10.6 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Page and Frame Replacement Algorithms
 Frame-Allocation Algorithm determines
 How many frames to give each process
 Which frames to replace
 Page-Replacement Algorithm
 Want lowest page-fault rate on both first access and re-access
 Evaluate algorithm by running it on a particular string of memory references
(reference string) and computing the number of page faults on that string
 String is just page numbers, not full addresses
 Repeated access to the same page does not cause a page fault
 Results depend on number of frames available
 In all our examples, the reference string of referenced page numbers is
7,0,1,2,0,3,0,4,2,3,0,3,0,3,2,1,2,0,1,7,0,1
10.7 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Graph: Page Faults vs. Number of Frames
10.8 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
First-In-First-Out (FIFO) Algorithm
 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)
 How many page faults we have?
 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
15 page faults
7 70 701 012
012
123 230 304 042 423 230
230 230
301 012
012 012
127 270 701
Q:
10.9 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
FIFO Illustrating Belady’s Anomaly
10.10 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Optimal Page Replacement Algorithm (OPT)
 Replace page that will not be used for the longest period of time
 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1
 Initially: {7: 2, 0: 7, 1: 4, 2: 4, 3: 4, 4: 1}
 9 is optimal page faults for the example
 How do you know this?
 Can’t read the future
 Used for measuring how well your algorithm performs
10.11 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Least Recently Used Algorithm (LRU)
 Use past knowledge rather than future knowledge
 Replace page that has been used the least amount of time
 Associate time of last use with each page
 12 faults – better than FIFO but worse than OPT
 Generally good algorithm and frequently used
 But how to implement?
10.12 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
LRU Algorithm (Cont.)
 Counter implementation
 Every page entry has a counter; every time page is referenced through this
entry, copy the clock into the counter
 When a page needs to be replaced, look at the counters to find smallest value
 Search through table needed (Bad)
 Stack implementation
 Keep a stack of page numbers in a double link form:
 Page referenced:
 move it to the top
 Example: requires 6 pointers to be changed
 But each update more expensive
 No search for replacement
 LRU and OPT are cases of stack algorithms that don’t have Belady’s Anomaly
10.13 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Use Of A Stack to Record Most Recent Page References
10.14 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
LRU Approximation Algorithms
 LRU needs special hardware and still slow
 Reference Bit
 With each page associate a bit, initially = 0
 When page is referenced, the bit set to 1
 Replace any with reference bit = 0 (if one exists)
 We do not know the order, however
 Second-Chance Algorithm
 Generally FIFO, plus hardware-provided reference bit
 Clock replacement
 If page to be replaced has
 Reference bit = 0  replace it
 Reference bit = 1 then:
– set reference bit 0, leave page in memory
– replace next page with bit = 0, subject to same rules
10.15 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Second-Chance (clock) Page-Replacement Algorithm
10.16 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Enhanced Second-Chance Algorithm
 Improve algorithm by using reference bit and modify bit (if available) in concert
 Take ordered pair (reference, modify):
 (0, 0) neither recently used not modified – best page to replace
 (0, 1) not recently used but modified – not quite as good, must write out
before replacement
 (1, 0) recently used but clean – probably will be used again soon
 (1, 1) recently used and modified – probably will be used again soon and
need to write out before replacement
 When page replacement called for, use the clock scheme but use the four
classes replace page in lowest non-empty class
 Might need to search circular queue several times
10.17 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Counting Algorithms
 Keep a counter of the number of references that have been made to each page
 Not common
 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
10.18 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Page-Buffering Algorithms
 Keep a pool of free frames, always
 Then frame available when needed, not found at fault time
 Read page into free frame and select victim to evict and add to free pool
 When convenient, evict victim
 Possibly, keep list of modified pages
 When backing store otherwise idle, write pages there and set to non-dirty
 Possibly, keep free frame contents intact and note what is in them
 If referenced again before reused, no need to load contents again from
disk
 Generally useful to reduce penalty if wrong victim frame selected
10.19 Silberschatz, Galvin and Gagne ©2018
Operating System Concepts – 10th Edition
Applications and Page Replacement
 All of these algorithms have OS guessing about future page access
 Some applications have better knowledge – i.e. databases
 Memory intensive applications can cause double buffering
 OS keeps copy of page in memory as I/O buffer
 Application keeps page in memory for its own work
 Operating system can given direct access to the disk, getting out of the way
of the applications
 Raw disk mode
 Bypasses buffering, locking, etc.

More Related Content

What's hot

Classification in data mining
Classification in data mining Classification in data mining
Classification in data mining Sulman Ahmed
 
Chapter 2 Operating System Structures.ppt
Chapter 2 Operating System Structures.pptChapter 2 Operating System Structures.ppt
Chapter 2 Operating System Structures.pptErenJeager20
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"Ra'Fat Al-Msie'deen
 
Chapter 2: Operating System Structures
Chapter 2: Operating System StructuresChapter 2: Operating System Structures
Chapter 2: Operating System StructuresShafaan Khaliq Bhatti
 
Structure of the page table
Structure of the page tableStructure of the page table
Structure of the page tableduvvuru madhuri
 
Chapter 10 Operating Systems silberschatz
Chapter 10 Operating Systems silberschatzChapter 10 Operating Systems silberschatz
Chapter 10 Operating Systems silberschatzGiulianoRanauro
 
data structures- back tracking
data structures- back trackingdata structures- back tracking
data structures- back trackingAbinaya B
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating systemSara Ali
 
Splay Tree Algorithm
Splay Tree AlgorithmSplay Tree Algorithm
Splay Tree Algorithmsathish sak
 

What's hot (20)

Main Memory
Main MemoryMain Memory
Main Memory
 
Chapter 8 - Main Memory
Chapter 8 - Main MemoryChapter 8 - Main Memory
Chapter 8 - Main Memory
 
Paging and segmentation
Paging and segmentationPaging and segmentation
Paging and segmentation
 
Classification in data mining
Classification in data mining Classification in data mining
Classification in data mining
 
Memory management
Memory managementMemory management
Memory management
 
Chapter 2 Operating System Structures.ppt
Chapter 2 Operating System Structures.pptChapter 2 Operating System Structures.ppt
Chapter 2 Operating System Structures.ppt
 
Operating Systems - "Chapter 4: Multithreaded Programming"
Operating Systems - "Chapter 4:  Multithreaded Programming"Operating Systems - "Chapter 4:  Multithreaded Programming"
Operating Systems - "Chapter 4: Multithreaded Programming"
 
Ch1-Operating System Concepts
Ch1-Operating System ConceptsCh1-Operating System Concepts
Ch1-Operating System Concepts
 
Memory management
Memory managementMemory management
Memory management
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Memory virtualization
Memory virtualizationMemory virtualization
Memory virtualization
 
Chapter 2: Operating System Structures
Chapter 2: Operating System StructuresChapter 2: Operating System Structures
Chapter 2: Operating System Structures
 
Structure of the page table
Structure of the page tableStructure of the page table
Structure of the page table
 
Chapter 10 Operating Systems silberschatz
Chapter 10 Operating Systems silberschatzChapter 10 Operating Systems silberschatz
Chapter 10 Operating Systems silberschatz
 
data structures- back tracking
data structures- back trackingdata structures- back tracking
data structures- back tracking
 
Deadlocks in operating system
Deadlocks in operating systemDeadlocks in operating system
Deadlocks in operating system
 
Swapping | Computer Science
Swapping | Computer ScienceSwapping | Computer Science
Swapping | Computer Science
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
 
Database System Architectures
Database System ArchitecturesDatabase System Architectures
Database System Architectures
 
Splay Tree Algorithm
Splay Tree AlgorithmSplay Tree Algorithm
Splay Tree Algorithm
 

Similar to Page Replacement Algorithms.pptx

Similar to Page Replacement Algorithms.pptx (20)

LecturePPT_Unit_3b_AY2021-22_TechngVrsn.ppt
LecturePPT_Unit_3b_AY2021-22_TechngVrsn.pptLecturePPT_Unit_3b_AY2021-22_TechngVrsn.ppt
LecturePPT_Unit_3b_AY2021-22_TechngVrsn.ppt
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
ch9.ppt
ch9.pptch9.ppt
ch9.ppt
 
Ch8 of OS
Ch8 of OSCh8 of OS
Ch8 of OS
 
Ch9
Ch9Ch9
Ch9
 
Memory Management
 Memory Management Memory Management
Memory Management
 
بيي
بييبيي
بيي
 
Galvin-operating System(Ch10)
Galvin-operating System(Ch10)Galvin-operating System(Ch10)
Galvin-operating System(Ch10)
 
Allocating of Frames.pptx
Allocating of Frames.pptxAllocating of Frames.pptx
Allocating of Frames.pptx
 
9.Virtual Memory
9.Virtual Memory9.Virtual Memory
9.Virtual Memory
 
unit 4 virtual memory.ppt
unit 4 virtual memory.pptunit 4 virtual memory.ppt
unit 4 virtual memory.ppt
 
Ch8
Ch8Ch8
Ch8
 
advanced operating systems chapter 9 virtual memory
advanced operating systems chapter 9 virtual memoryadvanced operating systems chapter 9 virtual memory
advanced operating systems chapter 9 virtual memory
 
OSCh10
OSCh10OSCh10
OSCh10
 
Ch10 OS
Ch10 OSCh10 OS
Ch10 OS
 
OS_Ch10
OS_Ch10OS_Ch10
OS_Ch10
 
Ch10: Virtual Memory
Ch10: Virtual MemoryCh10: Virtual Memory
Ch10: Virtual Memory
 
Ch09
Ch09Ch09
Ch09
 
Ch9 Virtual Memory
Ch9 Virtual MemoryCh9 Virtual Memory
Ch9 Virtual Memory
 
Chapter 9 Operating Systems silberschatz
Chapter 9 Operating Systems silberschatzChapter 9 Operating Systems silberschatz
Chapter 9 Operating Systems silberschatz
 

More from infomerlin

GSC-21_029_4_09_TSDSI-R1-1.pptx
GSC-21_029_4_09_TSDSI-R1-1.pptxGSC-21_029_4_09_TSDSI-R1-1.pptx
GSC-21_029_4_09_TSDSI-R1-1.pptxinfomerlin
 
Segmentation.ppt
Segmentation.pptSegmentation.ppt
Segmentation.pptinfomerlin
 
Contiguous Memory Allocation.ppt
Contiguous Memory Allocation.pptContiguous Memory Allocation.ppt
Contiguous Memory Allocation.pptinfomerlin
 
Allocating Kernel Memory.pptx
Allocating Kernel Memory.pptxAllocating Kernel Memory.pptx
Allocating Kernel Memory.pptxinfomerlin
 
Deadlock Detection.pptx
Deadlock Detection.pptxDeadlock Detection.pptx
Deadlock Detection.pptxinfomerlin
 
Deadlock Prevention.pptx
Deadlock Prevention.pptxDeadlock Prevention.pptx
Deadlock Prevention.pptxinfomerlin
 
Frame detection.pdf
Frame detection.pdfFrame detection.pdf
Frame detection.pdfinfomerlin
 
Deadlock Backgroud.pptx
Deadlock Backgroud.pptxDeadlock Backgroud.pptx
Deadlock Backgroud.pptxinfomerlin
 
5G Hackathon - Brainstorming Session.pptx
5G Hackathon - Brainstorming Session.pptx5G Hackathon - Brainstorming Session.pptx
5G Hackathon - Brainstorming Session.pptxinfomerlin
 
Lecture 4.pptx
Lecture 4.pptxLecture 4.pptx
Lecture 4.pptxinfomerlin
 
System Calls.ppt
System Calls.pptSystem Calls.ppt
System Calls.pptinfomerlin
 
Lec 6 OS structure and Operations.ppt
Lec 6 OS structure and Operations.pptLec 6 OS structure and Operations.ppt
Lec 6 OS structure and Operations.pptinfomerlin
 
cs-intro-os.ppt
cs-intro-os.pptcs-intro-os.ppt
cs-intro-os.pptinfomerlin
 
Lecture-2 Signal-Spectra-Modulation.pptx
Lecture-2 Signal-Spectra-Modulation.pptxLecture-2 Signal-Spectra-Modulation.pptx
Lecture-2 Signal-Spectra-Modulation.pptxinfomerlin
 
Noise in AM systems.ppt
Noise in AM systems.pptNoise in AM systems.ppt
Noise in AM systems.pptinfomerlin
 
Lecture 22 Threshold effects in FM.pptx
Lecture 22 Threshold effects in FM.pptxLecture 22 Threshold effects in FM.pptx
Lecture 22 Threshold effects in FM.pptxinfomerlin
 
Lecture-5 AM Signal Generation – Type 1.pptx
Lecture-5 AM Signal Generation – Type 1.pptxLecture-5 AM Signal Generation – Type 1.pptx
Lecture-5 AM Signal Generation – Type 1.pptxinfomerlin
 
Lecture-3 Need for Modulation.pptx
Lecture-3 Need for Modulation.pptxLecture-3 Need for Modulation.pptx
Lecture-3 Need for Modulation.pptxinfomerlin
 

More from infomerlin (20)

GSC-21_029_4_09_TSDSI-R1-1.pptx
GSC-21_029_4_09_TSDSI-R1-1.pptxGSC-21_029_4_09_TSDSI-R1-1.pptx
GSC-21_029_4_09_TSDSI-R1-1.pptx
 
sat-ppt.pptx
sat-ppt.pptxsat-ppt.pptx
sat-ppt.pptx
 
Segmentation.ppt
Segmentation.pptSegmentation.ppt
Segmentation.ppt
 
Contiguous Memory Allocation.ppt
Contiguous Memory Allocation.pptContiguous Memory Allocation.ppt
Contiguous Memory Allocation.ppt
 
Allocating Kernel Memory.pptx
Allocating Kernel Memory.pptxAllocating Kernel Memory.pptx
Allocating Kernel Memory.pptx
 
Deadlock Detection.pptx
Deadlock Detection.pptxDeadlock Detection.pptx
Deadlock Detection.pptx
 
Deadlock Prevention.pptx
Deadlock Prevention.pptxDeadlock Prevention.pptx
Deadlock Prevention.pptx
 
Frame detection.pdf
Frame detection.pdfFrame detection.pdf
Frame detection.pdf
 
Deadlock Backgroud.pptx
Deadlock Backgroud.pptxDeadlock Backgroud.pptx
Deadlock Backgroud.pptx
 
5G Hackathon - Brainstorming Session.pptx
5G Hackathon - Brainstorming Session.pptx5G Hackathon - Brainstorming Session.pptx
5G Hackathon - Brainstorming Session.pptx
 
LNA.ppt
LNA.pptLNA.ppt
LNA.ppt
 
Lecture 4.pptx
Lecture 4.pptxLecture 4.pptx
Lecture 4.pptx
 
System Calls.ppt
System Calls.pptSystem Calls.ppt
System Calls.ppt
 
Lec 6 OS structure and Operations.ppt
Lec 6 OS structure and Operations.pptLec 6 OS structure and Operations.ppt
Lec 6 OS structure and Operations.ppt
 
cs-intro-os.ppt
cs-intro-os.pptcs-intro-os.ppt
cs-intro-os.ppt
 
Lecture-2 Signal-Spectra-Modulation.pptx
Lecture-2 Signal-Spectra-Modulation.pptxLecture-2 Signal-Spectra-Modulation.pptx
Lecture-2 Signal-Spectra-Modulation.pptx
 
Noise in AM systems.ppt
Noise in AM systems.pptNoise in AM systems.ppt
Noise in AM systems.ppt
 
Lecture 22 Threshold effects in FM.pptx
Lecture 22 Threshold effects in FM.pptxLecture 22 Threshold effects in FM.pptx
Lecture 22 Threshold effects in FM.pptx
 
Lecture-5 AM Signal Generation – Type 1.pptx
Lecture-5 AM Signal Generation – Type 1.pptxLecture-5 AM Signal Generation – Type 1.pptx
Lecture-5 AM Signal Generation – Type 1.pptx
 
Lecture-3 Need for Modulation.pptx
Lecture-3 Need for Modulation.pptxLecture-3 Need for Modulation.pptx
Lecture-3 Need for Modulation.pptx
 

Recently uploaded

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 

Recently uploaded (20)

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 

Page Replacement Algorithms.pptx

  • 1. Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Page Replacement Algorithms
  • 2. 10.2 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition What Happens if There is no Free Frame?  Issues and Policies:  What if all frames are used up by process pages?  What if there is a demand from the kernel, I/O buffers, etc.  How much to allocate to each process (what is the min and max)?  Page Replacement  Find some page in memory, but not really in use, page it out  If no frame is free, we find one that is not currently being used and free it  Algorithm – terminate? swap out? replace the page?  Performance – want an algorithm which will result in minimum number of page faults  What if the same page may be brought into memory several times  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  Page replacement completes separation between logical memory and physical memory – large virtual memory can be provided on a smaller physical memory
  • 3. 10.3 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Need For Page Replacement
  • 4. 10.4 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition 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 there is 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  Note:  Potentially 2 page transfers for page fault  increasing EAT
  • 5. 10.5 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Page Replacement
  • 6. 10.6 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Page and Frame Replacement Algorithms  Frame-Allocation Algorithm determines  How many frames to give each process  Which frames to replace  Page-Replacement Algorithm  Want lowest page-fault rate on both first access and re-access  Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string  String is just page numbers, not full addresses  Repeated access to the same page does not cause a page fault  Results depend on number of frames available  In all our examples, the reference string of referenced page numbers is 7,0,1,2,0,3,0,4,2,3,0,3,0,3,2,1,2,0,1,7,0,1
  • 7. 10.7 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Graph: Page Faults vs. Number of Frames
  • 8. 10.8 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition First-In-First-Out (FIFO) Algorithm  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)  How many page faults we have?  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 15 page faults 7 70 701 012 012 123 230 304 042 423 230 230 230 301 012 012 012 127 270 701 Q:
  • 9. 10.9 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition FIFO Illustrating Belady’s Anomaly
  • 10. 10.10 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Optimal Page Replacement Algorithm (OPT)  Replace page that will not be used for the longest period of time  7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1  Initially: {7: 2, 0: 7, 1: 4, 2: 4, 3: 4, 4: 1}  9 is optimal page faults for the example  How do you know this?  Can’t read the future  Used for measuring how well your algorithm performs
  • 11. 10.11 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Least Recently Used Algorithm (LRU)  Use past knowledge rather than future knowledge  Replace page that has been used the least amount of time  Associate time of last use with each page  12 faults – better than FIFO but worse than OPT  Generally good algorithm and frequently used  But how to implement?
  • 12. 10.12 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition LRU Algorithm (Cont.)  Counter implementation  Every page entry has a counter; every time page is referenced through this entry, copy the clock into the counter  When a page needs to be replaced, look at the counters to find smallest value  Search through table needed (Bad)  Stack implementation  Keep a stack of page numbers in a double link form:  Page referenced:  move it to the top  Example: requires 6 pointers to be changed  But each update more expensive  No search for replacement  LRU and OPT are cases of stack algorithms that don’t have Belady’s Anomaly
  • 13. 10.13 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Use Of A Stack to Record Most Recent Page References
  • 14. 10.14 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition LRU Approximation Algorithms  LRU needs special hardware and still slow  Reference Bit  With each page associate a bit, initially = 0  When page is referenced, the bit set to 1  Replace any with reference bit = 0 (if one exists)  We do not know the order, however  Second-Chance Algorithm  Generally FIFO, plus hardware-provided reference bit  Clock replacement  If page to be replaced has  Reference bit = 0  replace it  Reference bit = 1 then: – set reference bit 0, leave page in memory – replace next page with bit = 0, subject to same rules
  • 15. 10.15 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Second-Chance (clock) Page-Replacement Algorithm
  • 16. 10.16 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Enhanced Second-Chance Algorithm  Improve algorithm by using reference bit and modify bit (if available) in concert  Take ordered pair (reference, modify):  (0, 0) neither recently used not modified – best page to replace  (0, 1) not recently used but modified – not quite as good, must write out before replacement  (1, 0) recently used but clean – probably will be used again soon  (1, 1) recently used and modified – probably will be used again soon and need to write out before replacement  When page replacement called for, use the clock scheme but use the four classes replace page in lowest non-empty class  Might need to search circular queue several times
  • 17. 10.17 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Counting Algorithms  Keep a counter of the number of references that have been made to each page  Not common  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
  • 18. 10.18 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Page-Buffering Algorithms  Keep a pool of free frames, always  Then frame available when needed, not found at fault time  Read page into free frame and select victim to evict and add to free pool  When convenient, evict victim  Possibly, keep list of modified pages  When backing store otherwise idle, write pages there and set to non-dirty  Possibly, keep free frame contents intact and note what is in them  If referenced again before reused, no need to load contents again from disk  Generally useful to reduce penalty if wrong victim frame selected
  • 19. 10.19 Silberschatz, Galvin and Gagne ©2018 Operating System Concepts – 10th Edition Applications and Page Replacement  All of these algorithms have OS guessing about future page access  Some applications have better knowledge – i.e. databases  Memory intensive applications can cause double buffering  OS keeps copy of page in memory as I/O buffer  Application keeps page in memory for its own work  Operating system can given direct access to the disk, getting out of the way of the applications  Raw disk mode  Bypasses buffering, locking, etc.