2016 final exam posted
barbers in single source file: pros & cons?
linked-in policy: former students
tonight: penultimate lecture
schedule: final exam originally scheduled Wednesday
assignment 3
assignment 4
final: no news yet
modern architectures: hierarchical memory
memory-mapped I/O
non-VM systems: allocate main memory to processes TODO: diagram
problem: programs lcation in main memory changes from run to run
still have the problem of external (between processes) fragmentation
base register specifies starting point
limit register specifies max address
process (virtual) address: starts at 0
contiguous
segmentation: multiple contiguous blocks
paging
fixed-size vs. variable-sized partition
memory compaction
different types of data
object file: sections (data structure)
use hardware architecture similar to contiguous, but with multiple segment registers (base & limit)
wild pointer: segmentation violation
divide memory into "frames*
logical adddress space: 0..N-1
each process (data structure in kernel) maintains page table with mapping from virtual pages to physical frames TODO: diagram
TODO: diagram
TODO: diagram
phys_addr = *(BR + logical >> 12) | (logical & 0xFFF)
problem: loading logical memory values requires 2 memory accesses: ~200 cycles
solution: TLB (Translation Lookaside Buffer) within MMY TODO: diagram
TLB flush/purge on context switch
32-bit architecture: 20-bit page & 12-bit offset
64-bit architecture: 3-level table
effective memory access time: TLB hit time * hit rate + TLB miss time * (1 - hit rate)
TLB miss stalls the processor (cost of context switch would be much higher)
many processes running concurrently
solution: store some pages on disk, load into memory only when needed
internal fragmentation: logical space is not an even multiple of page size
minimize fragmentation by using smaller page size
paging architecture: page table has valid/invalid flag
page fault: if required page is not in memory, load page from swap space (disk)
working set theory: paging works because, typically, only a small subset of the pages are active at any given moment
shared library: save space by loading single copy of library code for all processes
shared memory: interprocess communication
garbage collection breaks working set theory
page table provides additional info
shared memory: 2 virtual pages share same physical memory
fork: 2 processes share data pages until one process alters a page
a page that is swapped out, then swapped back in has 2 copies (one in memory, one on disk)
if the page to be swapped out again has not been changed, i.e. clean, we can save the cost of a disk write (since it's already on disk)
if page is "written", page is marked "dirty" and must be written to disk when swapped out
if we have to swap a page out, the next time we have to use it, it will trigger another page fault
timing:
disk is 10,000 to 100,000 times slower than memory
memory is the new disk; disk is the new tape
even in its heyday, a heavily loaded system would start "thrashing"
when thrashing occurs, CPU utilization decreases
solution: suspend some processes
cache: fast on-chip memory
goal: minimize the number of page faults
optimal algorithm (theoretical/post-hoc empirical)
can use optimal result as baseline for evaluating other (heuristic) approaches
first-in/first-out: swap out "oldest" page in memory
least-recently-used (LRU)
approximation using reference bits
second-chance algorithm
why is LRU heuristic effective?
garbage collection destroys the working set
can determine working set approximations