Virtual Memory Concepts, Lecture Slide - Computer Science, Slides of Computer System Design and Architecture

Address Space, VM as Caching, Memory Management, Memory Protection ,Address Translation

Typology: Slides

2010/2011

Uploaded on 10/08/2011

rolla45
rolla45 🇺🇸

4

(6)

133 documents

1 / 36

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Carnegie Mellon
1
Virtual(Memory:(Concepts(
15#213:'Introduc0on'to'Computer'Systems ''
15th'Lecture,'Oct.'14,'2010'
Instructors:''
Randy'Bryant'and'Dave'O’Hallaron'
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24

Partial preview of the text

Download Virtual Memory Concepts, Lecture Slide - Computer Science and more Slides Computer System Design and Architecture in PDF only on Docsity!

Virtual Memory: Concepts

15-­‐213: Introduc0on to Computer Systems

th

Lecture, Oct. 14, 2010

Instructors:

Randy Bryant and Dave O’Hallaron

Today

 Address spaces

 VM as a tool for caching

 VM as a tool for memory management

 VM as a tool for memory protec;on

 Address transla;on

A System Using Virtual Addressing

 Used in all modern servers, desktops, and laptops

 One of the great ideas in computer science

M-­‐1:

Main memory

MMU

Physical address (PA) Data word 8: ...

CPU

Virtual address (VA) CPU Chip

Address Spaces

 Linear address space: Ordered set of con0guous non-­‐nega0ve integer

addresses:

 Virtual address space: Set of N = 2

n

virtual addresses

{0, 1, 2, 3, …, N-­‐1}

 Physical address space: Set of M = 2

m

physical addresses

{0, 1, 2, 3, …, M-­‐1}

 Clean dis;nc;on between data (bytes) and their aVributes (addresses)

 Each object can now have mul;ple addresses

 Every byte in main memory:

one physical address, one (or more) virtual addresses

Today

 Address spaces

 VM as a tool for caching

 VM as a tool for memory management

 VM as a tool for memory protec;on

 Address transla;on

VM as a Tool for Caching

 Virtual memory is an array of N con;guous bytes stored

on disk.

 The contents of the array on disk are cached in physical

memory ( DRAM cache )

 These cache blocks are called pages (size is P = 2

p

bytes)

PP 2m-­‐p-­‐

Physical memory

Empty Empty Uncached

VP 0

VP 1

VP 2n-­‐p-­‐

Virtual memory

Unallocated Cached Uncached Unallocated Cached Uncached

PP 0

PP 1

Empty Cached 0 N-­‐ M-­‐ 0

Virtual pages (VPs)

stored on disk

Physical pages (PPs)

cached in DRAM

Page Tables

 A page table is an array of page table entries (PTEs) that

maps virtual pages to physical pages.

 Per-­‐process kernel data structure in DRAM

null null

Memory resident

page table

(DRAM)

Physical memory

(DRAM)

VP 7

VP 4

Virtual memory

(disk)

Valid

Physical page

number or

disk address

PTE 0

PTE 7

PP 0

VP 2

VP 1

PP 3

VP 1

VP 2

VP 4

VP 6

VP 7

VP 3

Page Hit

 Page hit: reference to VM word that is in physical memory

(DRAM cache hit)

null null

Memory resident

page table

(DRAM)

Physical memory

(DRAM)

VP 7

VP 4

Virtual memory

(disk)

Valid

Physical page

number or

disk address

PTE 0

PTE 7

PP 0

VP 2

VP 1

PP 3

VP 1

VP 2

VP 4

VP 6

VP 7

VP 3

Virtual address

Handling Page Fault

 Page miss causes page fault (an excep0on)

null null

Memory resident

page table

(DRAM)

Physical memory

(DRAM)

VP 7

VP 4

Virtual memory

(disk)

Valid

Physical page

number or

disk address

PTE 0

PTE 7

PP 0

VP 2

VP 1

PP 3

VP 1

VP 2

VP 4

VP 6

VP 7

VP 3

Virtual address

Handling Page Fault

 Page miss causes page fault (an excep0on)

 Page fault handler selects a vic0m to be evicted (here VP 4)

null null

Memory resident

page table

(DRAM)

Physical memory

(DRAM)

VP 7

VP 4

Virtual memory

(disk)

Valid

Physical page

number or

disk address

PTE 0

PTE 7

PP 0

VP 2

VP 1

PP 3

VP 1

VP 2

VP 4

VP 6

VP 7

VP 3

Virtual address

Handling Page Fault

 Page miss causes page fault (an excep0on)

 Page fault handler selects a vic0m to be evicted (here VP 4)

 Offending instruc0on is restarted: page hit!

null null

Memory resident

page table

(DRAM)

Physical memory

(DRAM)

VP 7

VP 3

Virtual memory

(disk)

Valid

Physical page

number or

disk address

PTE 0

PTE 7

PP 0

VP 2

VP 1

PP 3

VP 1

VP 2

VP 4

VP 6

VP 7

VP 3

Virtual address

Locality to the Rescue Again!

 Virtual memory works because of locality

 At any point in ;me, programs tend to access a set of ac;ve

virtual pages called the working set

 Programs with beger temporal locality will have smaller working sets

 If (working set size < main memory size)

 Good performance for one process aier compulsory misses

 If ( SUM(working set sizes) > main memory size )

 Thrashing: Performance meltdown where pages are swapped (copied)

in and out con0nuously

19

VM as a Tool for Memory Management

 Key idea: each process has its own virtual address space

 It can view memory as a simple linear array

 Mapping func0on scagers addresses through physical memory

 Well chosen mappings simplify memory alloca0on and management

Virtual Address Space for Process 1: Physical Address Space (DRAM)

N-­‐

(e.g., read-­‐only library code) Virtual Address Space for Process 2:

VP 1

VP 2

N-­‐

VP 1

VP 2

PP 2

PP 6

PP 8

M-­‐

Address

translaHon

20

VM as a Tool for Memory Management

 Memory alloca;on

 Each virtual page can be mapped to any physical page

 A virtual page can be stored in different physical pages at different 0mes

 Sharing code and data among processes

 Map virtual pages to the same physical page (here: PP 6)

Virtual Address Space for Process 1: Physical Address Space (DRAM)

N-­‐

(e.g., read-­‐only library code) Virtual Address Space for Process 2:

VP 1

VP 2

N-­‐

VP 1

VP 2

PP 2

PP 6

PP 8

M-­‐

Address

translaHon