SlideShare a Scribd company logo
1 of 18
Download to read offline
CSE 3201
OPERATING SYSTEMS
Paging
► Paging is a memory-management scheme that permits the physical address space of a
process to be noncontiguous.
► Paging avoids external fragmentation and the need for compaction.
► When some code fragments or data residing in main memory need to be swapped out,
space must be found on the backing store.
► The backing store has the same fragmentation problems discussed in connection with
main memory
Paging Hardware
Paging mechanism
Paging Model of logical and
Physical memory Paging with 32 byte memory with 4 byte
paging
► There is no external fragmentation, but internal fragmentation exists.
► Expected fragmentation is average one-half page per process.
► Smaller page size is desirable but it has overhead.
► With larger page size disk IO is more efficient.
Multi level page table
Page Table entry structure
Present/absent –
1 – the entry is valid and can be used
0 – virtual page to which the entry belongs and is not currently in memory.
Protection –
1 – read only
0 – read/write
Modified and Referenced – keeps track of memory usage.
Caching –
Important for pages that map to register rather than memory.
Page Fault
► What happens if the program references an unmapped address?
- The MMU notices that the page is unmapped and causes the CPU to trap to the
operating system. This trap is called a page fault.
► The operating system picks a little-used page frame and writes its contents back to the disk
(if it is not already there).
► It then fetches (also from the disk) the page that was just referenced into the page frame
just freed, changes the map, and restarts the trapped instruction.
The Optimal Page Replacement Algorithm
► The page with the highest label should be removed.
► Suppose, one page will not be used for 8 million instructions and another will not be used
for 6 million instructions.
► This algorithm is not realizable as we don’t know which page is going to be used next.
The Not Recently Used Page Replacement
Algorithm
► The Referenced and Modified bit are used to decide the Not Recently Used Page.
► R is set whenever the page is referenced (read or written). M is set when the page is written to (i.e.,
modified).
► When a process is started up, all of its page table entries are marked as not in memory. As soon as any
page is referenced, a page fault will occur.
► The operating system then sets the R bit (in its internal tables), changes the page table entry to point to the
correct page, with mode READ ONLY, and restarts the instruction.
► If the page is subsequently modified, another page fault will occur, allowing the operating system to set
the M bit and change the page’s mode to READ/WRITE.
► Periodically (e.g., on each clock interrupt), the R bit is cleared, to distinguish pages that have not been
referenced recently from those that have been.
The Not Recently Used Page Replacement
Algorithm
► When a page fault occurs, the operating system inspects all the pages and divides them
into four categories based on the current values of their R and M bits:
► Class 0: not referenced, not modified.
► Class 1: not referenced, modified.
► Class 2: referenced, not modified.
► Class 3: referenced, modified.
► The NRU (Not Recently Used) algorithm removes a page at random from the
lowest-numbered nonempty class.
The First-In, First-Out (FIFO) Page
Replacement Algorithm
► The operating system maintains a list of all pages currently in memory, with the most
recent arrival at the tail and the least recent arrival at the head.
► On a page fault, the page at the head is removed and the new page added to the tail of the
list.
► One problem exists. What it can be?
The Second-Chance Page Replacement
Algorithm
► A simple modification to FIFO that avoids the problem of throwing out a heavily used
page is to inspect the R bit of the oldest page.
► If it is 0, the page is both old and unused, so it is replaced immediately.
► If the R bit is 1, the bit is cleared, the page is put onto the end of the list of pages, and its
load time is updated as though it had just arrived in memory. Then the search continues.
The Second-Chance Page Replacement
Algorithm
The Clock Page Replacement Algorithm
The Least Recently Used (LRU) Page
Replacement Algorithm
► Pages that have been heavily used in the last few instructions will probably be heavily
used again soon.
► Pages that have not been used for ages will probably remain unused for a long time.
► When a page fault occurs, throw out the page that has been unused for the longest time.
► How can we find LRU pages?
- One possible way is to implement hardware(!).
- Maintain a counter for counting instructions. Add a special field to attach this number to
each page table entry. What to do with this numbers?
Next
► More Page replacement algorithms

More Related Content

Similar to 4.-CSE-3201_OL1_Paging.pdf

Similar to 4.-CSE-3201_OL1_Paging.pdf (20)

virtual memory Operating system
virtual memory Operating system virtual memory Operating system
virtual memory Operating system
 
Operating System
Operating SystemOperating System
Operating System
 
Demand paging
Demand pagingDemand paging
Demand paging
 
Chapter 9 - Virtual Memory
Chapter 9 - Virtual MemoryChapter 9 - Virtual Memory
Chapter 9 - Virtual Memory
 
Ch09
Ch09Ch09
Ch09
 
Memory management
Memory managementMemory management
Memory management
 
page replacement.pptx
page replacement.pptxpage replacement.pptx
page replacement.pptx
 
Page replacement algorithms
Page replacement algorithmsPage replacement algorithms
Page replacement algorithms
 
Distributed Operating System_3
Distributed Operating System_3Distributed Operating System_3
Distributed Operating System_3
 
Mem mgt
Mem mgtMem mgt
Mem mgt
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
 
Page Replacement
Page ReplacementPage Replacement
Page Replacement
 
LRU_Replacement-Policy.pdf
LRU_Replacement-Policy.pdfLRU_Replacement-Policy.pdf
LRU_Replacement-Policy.pdf
 
ikh311-06
ikh311-06ikh311-06
ikh311-06
 
Memory management
Memory managementMemory management
Memory management
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
Sucet os module_4_notes
Sucet os module_4_notesSucet os module_4_notes
Sucet os module_4_notes
 
Operating system 38 page replacement
Operating system 38 page replacementOperating system 38 page replacement
Operating system 38 page replacement
 
Virtual Memory in Operating System
Virtual Memory in Operating SystemVirtual Memory in Operating System
Virtual Memory in Operating System
 
Unix Memory Management - Operating Systems
Unix Memory Management - Operating SystemsUnix Memory Management - Operating Systems
Unix Memory Management - Operating Systems
 

Recently uploaded

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
(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
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
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
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...Call girls in Ahmedabad High profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
(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
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
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
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
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
 

Recently uploaded (20)

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
(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
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
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
 
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
High Profile Call Girls Dahisar Arpita 9907093804 Independent Escort Service ...
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
(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...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
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
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
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...
 

4.-CSE-3201_OL1_Paging.pdf

  • 2. Paging ► Paging is a memory-management scheme that permits the physical address space of a process to be noncontiguous. ► Paging avoids external fragmentation and the need for compaction.
  • 3. ► When some code fragments or data residing in main memory need to be swapped out, space must be found on the backing store. ► The backing store has the same fragmentation problems discussed in connection with main memory
  • 5. Paging mechanism Paging Model of logical and Physical memory Paging with 32 byte memory with 4 byte paging
  • 6. ► There is no external fragmentation, but internal fragmentation exists. ► Expected fragmentation is average one-half page per process. ► Smaller page size is desirable but it has overhead. ► With larger page size disk IO is more efficient.
  • 8. Page Table entry structure Present/absent – 1 – the entry is valid and can be used 0 – virtual page to which the entry belongs and is not currently in memory. Protection – 1 – read only 0 – read/write Modified and Referenced – keeps track of memory usage. Caching – Important for pages that map to register rather than memory.
  • 9. Page Fault ► What happens if the program references an unmapped address? - The MMU notices that the page is unmapped and causes the CPU to trap to the operating system. This trap is called a page fault. ► The operating system picks a little-used page frame and writes its contents back to the disk (if it is not already there). ► It then fetches (also from the disk) the page that was just referenced into the page frame just freed, changes the map, and restarts the trapped instruction.
  • 10. The Optimal Page Replacement Algorithm ► The page with the highest label should be removed. ► Suppose, one page will not be used for 8 million instructions and another will not be used for 6 million instructions. ► This algorithm is not realizable as we don’t know which page is going to be used next.
  • 11. The Not Recently Used Page Replacement Algorithm ► The Referenced and Modified bit are used to decide the Not Recently Used Page. ► R is set whenever the page is referenced (read or written). M is set when the page is written to (i.e., modified). ► When a process is started up, all of its page table entries are marked as not in memory. As soon as any page is referenced, a page fault will occur. ► The operating system then sets the R bit (in its internal tables), changes the page table entry to point to the correct page, with mode READ ONLY, and restarts the instruction. ► If the page is subsequently modified, another page fault will occur, allowing the operating system to set the M bit and change the page’s mode to READ/WRITE. ► Periodically (e.g., on each clock interrupt), the R bit is cleared, to distinguish pages that have not been referenced recently from those that have been.
  • 12. The Not Recently Used Page Replacement Algorithm ► When a page fault occurs, the operating system inspects all the pages and divides them into four categories based on the current values of their R and M bits: ► Class 0: not referenced, not modified. ► Class 1: not referenced, modified. ► Class 2: referenced, not modified. ► Class 3: referenced, modified. ► The NRU (Not Recently Used) algorithm removes a page at random from the lowest-numbered nonempty class.
  • 13. The First-In, First-Out (FIFO) Page Replacement Algorithm ► The operating system maintains a list of all pages currently in memory, with the most recent arrival at the tail and the least recent arrival at the head. ► On a page fault, the page at the head is removed and the new page added to the tail of the list. ► One problem exists. What it can be?
  • 14. The Second-Chance Page Replacement Algorithm ► A simple modification to FIFO that avoids the problem of throwing out a heavily used page is to inspect the R bit of the oldest page. ► If it is 0, the page is both old and unused, so it is replaced immediately. ► If the R bit is 1, the bit is cleared, the page is put onto the end of the list of pages, and its load time is updated as though it had just arrived in memory. Then the search continues.
  • 15. The Second-Chance Page Replacement Algorithm
  • 16. The Clock Page Replacement Algorithm
  • 17. The Least Recently Used (LRU) Page Replacement Algorithm ► Pages that have been heavily used in the last few instructions will probably be heavily used again soon. ► Pages that have not been used for ages will probably remain unused for a long time. ► When a page fault occurs, throw out the page that has been unused for the longest time. ► How can we find LRU pages? - One possible way is to implement hardware(!). - Maintain a counter for counting instructions. Add a special field to attach this number to each page table entry. What to do with this numbers?
  • 18. Next ► More Page replacement algorithms