Operating Systems Lecture 16: Paging and Page Replacement Algorithms, Study notes of Operating Systems

The concepts of paging in operating systems, including the cost of paging and page replacement algorithms such as belady's algorithm and fifo. The document also discusses the advantages and disadvantages of different page replacement strategies and approximate lru algorithms.

Typology: Study notes

Pre 2010

Uploaded on 08/16/2009

koofers-user-e9w
koofers-user-e9w 🇺🇸

10 documents

1 / 12

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
COMP 310:
Operating Systems
Lecture 16:
Paging
October 11, 2004
Christine Alvarado
Cost of paging
Effecting access time is:
effective access time = (1 – p) * ma + p * page fault time
What is the effective access time if p = 0.01, ma = 100ns,
paging time = 25ms?
How can we ensure a degradation of less than 10%?
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Operating Systems Lecture 16: Paging and Page Replacement Algorithms and more Study notes Operating Systems in PDF only on Docsity!

COMP 310:

Operating Systems

Lecture 16:

Paging

October 11, 2004

Christine Alvarado

Cost of paging

 Effecting access time is:

effective access time = (1 – p ) * ma + p * page fault time

What is the effective access time if p = 0.01, ma = 100ns,

paging time = 25ms?

How can we ensure a degradation of less than 10%?

Page replacement: Goals  Reduce fault rate by selecting the “Best” page to replace  What is the best page in theory?  How can we come close to this? Belady’s Algorithm  Optimal page replacement algorithm  Evict the page that won’t be used for the longest time in the future.

FIFO: First-In First-Out  Replace the oldest page first 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 Physical Memory

Disk

FIFO Advantages/Disadvantages  Why use FIFO?  Why not use FIFO?  “Belady’s Anomaly” LRU: Least Recently Used  Replace the page that hasn’t been used in the longest time 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 Physical Memory

Disk

Approximate LRU algorithms  Use reference bit… to increment a counter

 Set ref bit to 1 when page is accessed (not loaded)

 At regular intervals do:

 If ref bit = 0, increment counter

 If ref bit = 1, zero counter

 zero reference bit

LRU Clock (Second Chance Algorithm)

Allocation of Frames  Fixed vs. Variable Space

Kernel space

P

P

P

Physical Memory

Page Fault Frequency  Page Fault Frequency (PFF) is a variable space algorithm that uses a more ad hoc approach

 Monitor page fault rate for each process

 If fault rate is high enough, give more memory

 Does more memory ALWAYS mean fewer PF?

 If fault rate is low enough, take away memory

 Problem #1? 0 0 1 0 1 2 0 1 1 0 1 2 3 4 5 3 3 5 4 4 3 3  Another problem? What if PFF is high for all processes? Working Set Size  Working set size is the number of pages in the working set  The working set size changes with program locality 1 2 4 0 2 1 2 4 7 3 3 2 7 3 3 4 3 3 1 3 3 3 3 3 1 3 3 6 3 7 7 7 0 0 1 1…

Thrashing Revisited  But sometimes physical memory is just not big enough  E.g. Windows 95 with 4MB of memory  Solutions? Next time  Assignment  6.3, 6.7, 6.10a+b, 8.4, 9.8, 9.

 See 9.8 supplement on the web

 Due Wednesday, Oct 20