Computer Science 440 Spring 2014
Gregory M. Kapfhammer
Keep in touch!

Office Hours, Email, Web, Twitter

Operating Systems
Memory Hierarchy
RAM
ROM
BIOS
Memory Management Unit
How do we ...
Organize
and Access
Memory?
No Memory Abstraction
All Access!
Multiple Programs?
Well ...
Yes and No
Swap All
Other Methods
But, Complications
Solution?
Address Space
Base and Limit Registers
Page 183
Not Enough Memory?
Swapping
Holes?
Memory Compaction
Growth Management
Free Memory
Bitmaps
0 = Free
1 = Allocated
Linked List
Allocate Memory
First Fit
Next Fit
Best Fit
Worst Fit
Quick Fit
Which is best?
How to determine?
Simulation
Virtual Memory
Challenge?
Large Programs
Many Programs
Small Physical Memory
Pages
Continuous range of addresses
Not all in physical memory
Paging
Virtual Addresses > Physical Addresses
MMU
Page Fault
Page Table
Input: Virtual Page
Output: Physical Page
Paging Challenges
Virtual to physical must be fast
Large virtual address space implies large page table
Locality to the rescue!
Few page table entries are heavily read
Keep those pages most needed
TLB
Dedicated hardware
Multiple levels of abstraction
"All problems in computer science can be solved by another level of indirection"
David Wheeler
Page Replacement
Page fault requires eviction
Why?
Which page for eviction?
Page replacement algorithms
Optimal
Label each page with the number of instructions executed before first reference
Not realistic!
Realistic but effective?
Determining "use" is hard!
R - referenced
M - modified
Contained in the page table
Updated on every memory reference
Set by the hardware
R cleared on clock interrupt
If we have a page fault ...
Four categories
Class 0: R=0, M=0
Class 1: R=0, M=1
Class 2: R=1, M=0
Class 3: R=1, M=1
NRU: Not recently used
NRU removes a page, at random, from the lowest class
FIFO
Linked list of all pages
If we have a page fault ...
Remove the page at the head
Drawbacks?
Don't remove pages that are recently referenced!
Second Chance
R=1 means reset and end of queue
But ...
Pages are always moved around the list
Clock
Page 206
R=0 : Evict
R=1 : Reset R and advance
Another alternative?
LRU
Linked list of all pages in memory
Update the list on every memory access!
Expensive
Dedicated hardware
Working Set
Denning
Page 210
Working Set + Clock = ?
WSClock
Count off by fours
MMU and the OS
Separate policy and mechanism