Virtual Memory - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

Virtual Memory

Description:

Virtual Memory. Art Munson. CS614 Presentation. February 10, 2004. VM Review. 0. 1. 6. 4 ... Portable: uniproc, multiproc, and distributed computers ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 26
Provided by: isci
Category:
Tags: memory | munson | virtual

less

Transcript and Presenter's Notes

Title: Virtual Memory


1
Virtual Memory
  • Art Munson
  • CS614 Presentation
  • February 10, 2004

2
VM Review
Virtual Memory (seen by application)
Efficient Translation?
0
1
6
4
Physical Memory
3
VM Review (II)
Virtual Memory (seen by application)
Lookup page
Page Table
6 Fr 2
1 Fr 3
TLB
Virt. Page Phys. Frame
0 0
1 3
2 -1

No
Found ?
Yes
0
1
6
4
Physical Memory
4
VM Pros/Cons
  • More address space
  • Per program
  • System-wide
  • Isolation / Protection
  • Ease of Cleanup
  • Complicates sharing memory
  • Performance
  • Context switches (cache, TLB)

Motivation multiple interactive programs on one
computer
5
Mach Goals
  • Portable uniproc, multiproc, and distributed
    computers
  • Support large, sparse virtual address space
  • Copy-on-write as VM operation
  • Efficient copy-on-write read-write memory
    sharing

6
Mach Goals (contd)
  • Memory mapped files
  • Allow generic user-provided backing store objects
    (and pagers)

7
Mach Memory Architecture
Address map
R/C
RW/N
RW/C
X/S
Memory objects
Pagers
??
Kernel
Machine Dependent Code
CPU
Phys. Memory
pmap
8
Key Architecture Decisions
  • Memory Objects
  • Data. Anywhere. Associated pager maps to address
    space(s).
  • Message Passing
  • Loosely coupled, allowing generality.
  • Simple semantics allows consistent API for
    distributed computing. Too simple?

9
Implementing Memory Sharing
  • Shadow objects proxies to support copy-on-write
    at page granularity.
  • Shared mapping provides coherency for read-write
    sharing

A
B
C
10
Page Table Tradeoffs
Pg 0 Fr 2
Pg 1 Fr 0
Pg 2 Disk

Pg 0-3
Pg 3-6
  • Normal due to large size (8MB), linear
    organization non-option

Pg 0 Fr 2
Pg 1 Fr 0
Pg 2 Disk

Fr 0 Pg 1
Fr 1 empty
Fr 2 Pg 0
Fr 3 Pg 6
Inverted query with hash function. Aliasing
clumsy / expensive
11
Mach VM Performance
12
Mach VM Performance (II)
13
Clever VM Hacks
  • Idea use page fault hardware to check simple
    application predicates.
  • OS provides hooks for application TRAP, PROT1,
    PROTN, UNPROT, DIRTY, MAP2
  • Implicit assumption that faulting page is in
    memory---i.e. app handles protection faults.

14
Pointer Forwarding
To-space
From-space
15
Pointer Forwarding (II)
To-space
From-space
16
Hack 1 Concurrent Garbage Collection
From-space
  • Initialize collecting
  • Stop mutator threads.
  • PROTN collection region.
  • MAP2 region so collector can access (not shown).
  • Copy roots registers to to-space.
  • Restart mutator threads.
  • Collecting thread starts scanning from-space.

To-space
17
Hack 1 Concurrent Garbage Collection (II)
From-space
Page fault
void trap_fault(pg) objList scanPage(pg)
foreach (o in objList) copy o to to-space
forward ptrs to o UNPROT(pg) rerun
faulting instr.
To-space
18
Hack 2 Shared Virtual Memory
19
Hack 2 Shared Virtual Memory (II)
CPU 1 faults when trying to write read-only B.
CPU 1
Give me up-to-date copy of B Then invalidate the
page.
a
B
c
d
e
f
g
h
Here you go.
CPU 5
CPU 1 now marks B as writeable and resumes
execution.
i
j
k
B
m
f
w
h
20
Hack 3 Concurrent Checkpointing
  • Goal save application state (registers
    memory).
  • Algorithm
  • Mark all pages read-only (PROTN).
  • Background thread concurrently copies pages to
    checkpoint, then marks read/write.
  • On write-fault, checkpoint thread backs up
    faulting page and marks writeable.

21
Other VM Algorithms
  • Generational garbage collection
  • Persistent stores
  • Extending address space in persistent stores
  • Data compression paging
  • Heap overflow detection

22
VM Primitive Performance
23
Is this a good idea?
  • View 1
  • Extending VM services provided by OS
  • Reduces instruction count gt better perf
  • Data properties determine program execution.
    Mach model easy logical fit.
  • So OS designers should improve efficiency of VM
    primitives.

24
Is this a good idea? (II)
  • View 2
  • Relies on knowledge of hardware, not an
    abstraction.
  • Introducing more page faults might degrade
    performance on current highly pipelined
    processors.
  • Able to enforce not looking at CPU state?
  • OS trust application code?

25
Summary
  • Rich set of memory abstractions enables VM for
    uniproc and multiproc computers.
  • Distributed computing tolerant of abstraction in
    practice?
  • Clever VM hacks may not adjust well to hardware
    changes.
Write a Comment
User Comments (0)
About PowerShow.com