Demand Paging

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 26

Virtual Memory

Demand Paging
Virtual Memory
• Is a technique that allows the execution of Ps that
may not be completely in memory.
• Advantage of this scheme is that programs can be
larger than physical memory.
• Ps to share files and address spaces.
• Benefits:
1. No constraint of the physical memory.
2. More programs can be run at the same time.
3. Less I/O would be needed.
VM is the separation of user logical memory
from physical memory.
Demand Paging
• Virtual memory is implemented by demand
paging.
• It is similar to a paging system with swapping.
Lazy swapper
• A lazy swapper never swaps a page into memory
unless that page will be needed.
• When a process to be swapped in, the pager
guesses which pages will be used before the
process is swapped out again.
• Instead of swapping the whole process, the
pager brings only those necessary pages into
memory.
• Valid-invalid bit is used. PT(1-BIT)=v,i
Access to a page marked “invalid” causes a
page-fault trap.
Pure demand paging
• Bring each page into memory until is required.
• Multiple page faults.
• The hardware support for demand paging is:
• Page table
• Secondary pages
Performance of demand paging
• Compute the effective memory access time.
• Memory access time, ma, 10 to 200 nano secs
Page Replacement
• Each page has faulted atmost once, when it is
first referenced.
• P=10/2=5 pages (only uses only one-half)
• If we need 40 frames, we could run 8
processes, ,…….degree of MP
Basic scheme
Page Replacement Algorithms
1. FIFO Page Replacement (oldest page is chosen)
Belady’s Anamoly
• The page fault rate may increase as the
number of frames increases.

• The number of faults for 4 frames(10)> the


number of faults 3 (9).
• For example, if we consider reference string
3, 2, 1, 0, 3, 2, 4, 3, 2, 1, 0, 4 and 3 slots,
• we get 9 total page faults, but if we increase
slots to 4, we get 10 page faults.
2. Optimal Page Replacement
• Replace the page that will not be used for the
longest period of time.
• Guarantees lowest possible page fault rate.
3. LRU Page Replacement
• Will replace the page that has not been used
for the longest period of time.
LRU Implementation
1. Counters (3….C=4……2 (4)….6(2)….5(1))….8(1)
2. Stack (4,7,0,1,2)…0…(4,7,1,2,0)…4…
(7,1,2,0,4)…8.. (1,2,0,4,8)
4. LRU Approximation Page Replacement

• Reference bit=1, whenever the page is


referenced. Are associated with each entry in
the page table.
4.1 Additional Reference-Bits Algorithm

• Keep an 8-bit byte for each page in memory.


• These 8-bit shift registers contain the history
of page use for the last 8 time periods.
4.2 Second Chance Algorithm
• Base is FIFO.
• When a page has been selected, inspect its reference
bit.
• =0, then replace this page.
• =1, we will give that page a second chance and move
onto the next FIFO page.
• When a page gets a second chance, its reference bit is
cleared and its arrival time is reset to the current time.
• Aging factor
4.3 Enhanced Second-Chance Algorithm

• Reference bit and modify bit as an ordered


pair.
5. Counter-Based Page Replacement
Algorithms
1. LFU (least frequently used): the page with
the smallest count.
2. MFU (most frequently used): is based on the
argument that the page with the smallest
count was probably just brought in and has
yet to be used. Replace the page with highest
count value.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy