|
Computer Science 322 Operating Systems Mount Holyoke College Spring 2010
|
|
Lecture 17: Page Replacement and Frame Allocation
Date: Wednesday, April 7, 2010
Agenda
- Announcements
- Final project proposals due Monday
- Lecture assignment recap
- Memory Management
- Page replacement algorithms
- Least Recently Used (LRU)
- select the page that we have not used for the
longest time
- actually used in practice
- direct implementation may involve timestamps or a
stack of page references
- may be too expensive to implement directly
- LRU approximation algorithms
- Second-chance or Clock Algorithm uses one reference
bit and a clock pointer, treating the frames of memory as
a circular array
- Gold's Clock Algorithm also considers a "dirty"
bit to try to avoid selecing pages that need to be written
back to disk because they are more expensive
- Counting algorithms
- Least-frequently used (LFU)
- Most-frequently used (MFU)
- not obvious why or when these are useful - something
to think about
- direct implementations may suffer from same overhead
costs as a direct implementation of LRU
- Frame allocation
- each process needs some number of frames
- pages for instructions, local data, global data
- how do we decide how many frames are allocated to each
process?
- equal allocation - everyone gets the same
- proportional allocation - processes get frames
proportional to the amount of logical memory
- priority allocation - prioritize memory like we
prioritize CPU scheduling
- local replacement vs. global replacement - does a victim
have to be selected from the page faulting process' frames?
- thrashing
- if we have too many processes, not enough frames to
keep a reasonably low page fault rate
- the medium-term scheduler may notice a low CPU
utilization (everyone's waiting on page faults) and add
more processes to the mix
- this will only make the situation worse
- need to be able to detect this and have the
medium-term or long-term scheduler reduce the degree of
multiprogramming
- Working set model
- each process will have a set of pages on which it is
working frequently at a given time
- this is the working set of a process
- a process' working set changes over time
- approximate the working set as the set of pages that
a process has accessed within some window of time into the
recent past
- if this working set window is too small, the working
set we detect will not encompass the true locality
- if it is too large, pages will remain in the working
set too long after the process has moved on
- total demand for frames in the system is the sum of
the working sets of all processes
- thrashing is likely when this total demand outstrips
availability
- this is used in reality in many modern systems
(Solaris, Windows NT, to name two)
- Lab 6 out
Lecture Assignment 17
Due at the start of class, Monday, April 12.
You need not submit answers to these
questions, but you will have a chance to ask questions about them at
the start of class.
- SG&G Practice Exercise 8.5, p. 351
- SG&G Exercise 8.12, p. 352
- SG&G Practice Exercise 9.2, p. 409
- SG&G Practice Exercise 9.10, p. 411
Please submit answers to these questions
either as a hard copy (typeset or handwritten are OK) or by email to
jteresco AT mtholyoke.edu by the start of class. We will discuss these questions at
the start of class, so no late submissions are accepted.
- SG&G Exercise 8.23, p. 353
- SG&G Exercise 9.8, p. 410 (Do only the cases of three, five, and seven frames)
- SG&G Exercise 9.28, p. 414