Docsity

Virtual Memory Primitives for User Programs - Lecture Notes | CS 533, Study notes of Computer Science

Partial preview of the text

Download Virtual Memory Primitives for User Programs - Lecture Notes | CS 533 and more Study notes Computer Science in PDF only on Docsity!

Virtual Memory Primitives for User

Programs

Andrew W. Appel and Kai Li

Presented by: Nish Aravamudan

May 17, 2006

Overview

●

Background

●

Necessary Primitives

●

Performance Considerations

●

System Design

●

Examples

Necessary Primitives

●

TRAP – Userspace page fault handler

●

PROT1/PROTN decrease accessibility of page(s)

●

UNPROT – increase accessibility of page

●

DIRTY – list of dirtied pages since last call

●

MAP2 – map same physical page to two different

virtual addresses, with different protections, in

same address space

Performance Comparison

●

The better the primitives perform, the better the

algorithms perform

Examples' Primitive Usage

Concurrent Garbage Collection

●

Synchronize collector and mutator

●

Based on Baker's algorithm

– At beginning of collection, all objects in from space,

to space is empty

– Collector traces graph of reachable objects, copying

each into to space

– Every time mutator allocates new object, invoke

collector

Concurrent Garbage Collection

●

VM protections detect from space references

and synchronize mutator/collector

– Unscanned area set to no access

– Mutator will get page access trap on unscanned

objects

– Collector handles trap, copying objects and

forwarding pointers

– Collector unprotects page and restarts mutator

– Collector also scans unscanned area concurrently

with mutator execution

Concurrent Garbage Collection

To space From reference [4]

Collector

Copies from space objects to unscanned

area

Scans objects for pointers to from space

objects

Copies object to unscanned area, if

necessary

Forwards pointers to to space

Once scanned == unscanned, all of

from space is garbage

Mutator

Allocates at new

In Baker's version, blocks while Collector

runs

Concurrent Garbage Collection

Time 1 Collector: Copies reachable objects (from registers) to to space Forwards pointers stored in registers

A

B

> C

> D

E

> F

G

> A

A

1 B 1

CC 1 DD 1

R/W

From Space To Space Registers

R

1

> A

1 R 2

> B

1

R/W

N/A

Concurrent Garbage Collection

Time 2 Collector: Protects unscanned area Starts mutator

A

B

> C

> D

E

> F

G

> A

From Space To Space Registers

R

1

> A

1 R 2

> B

1

R/W

N/A

A

1 B 1

C 1 D 1

R/W

Concurrent Garbage Collection

Later Mutator: Uses object E Page fault Assume G also reachable Collector: Handles page fault Remap page Copy / forward Unprotect Registers

R

1

> E E

1 R 2

> B

A

B

> C

> D

E

> F

G

> A

A

1 B 1

C 1 D 1 ... E 1 F

1 G 1

A 1

R/W

N/A

R/W

R/W

From Space (M) To Space

A

B

> C

> D

E

> F

G

> A

R/W

R/W

From Space (C)

Shared Virtual Memory

●

Multiple processor/memory nodes, connected

by fast message passing network

●

SVM presents large coherent shared memory

address space

●

Maintain single writer and multiple reader

coherence at page level

Many copies of read only pages, one copy of read

write pages

Concurrent Checkpointing

1) R/W > R/O

  1. Mark address space read only
  2. Restart application threads
  3. Copier thread copies pages to separate space
  4. Thread accesses uncopied page
  5. Copier handles page fault
  6. Copier restarts thread

Fault

R/W

R/W

Generational Garbage Collection

●

Two properties of dynamically allocated records

1) Younger records more likely to die soon

2) Younger records tend to point to older records

● All records in G

i

older than G

i+

nd

property means few or no pointers from G

i

to

G

j

, i < j

●

Collect in youngest generation

●

Detect assignments to old objects