Lecture_12_virtual_memory.pdf

Lecture_12_virtual_memory.pdf - Lecture 12 12 Virtual...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Lecture 12 ± Virtual Memory 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Levels of the Memory Hierarchy Upper Level CPU Registers Capacity Access Time egisters Staging Xfer Unit pp faster < 1K Bytes 0.25 – 0.5ns Cache 16 MB Bytes Registers Instr. Operands prog./compiler 1-8 bytes < 16 MB Bytes 0.5 - 25 ns Cache Blocks cache cntl 8-128 bytes Main Memory M< 16 GBytes 80 – 250 ns Memory ages OS Disk ¾ 100 G Bytes, 5 ms 000 000 ns) Disk Pages 512-4K bytes (5,000,000 ns) Tape finite ape Files user/operator Mbytes ower Level Larger 2 infinite sec-min Tape Lower Level
Background image of page 2
Virtual Memory: Motivation ± Virtual memory is a technique that uses main memory as a cache for econdary storage secondary storage. ± Allow safe sharing of memory among multiple programs Address translation Each program has its own address space (Virtual address) Virtual memory implements the translation from a program s address to physical address (provide protection) ± Allow a single user program to exceed the ize of physical memory size of physical memory ± Simplify loading a program for execution by providing relocation Disk addresses 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Virtual Memory Terminology ± Page or segment – A block transferred from the disk to main memory • Page: fixed size • Segment: variable size age fault ± Page fault – The requested page is not in main memory (miss) ddress translation or memory mapping ± Address translation or memory mapping – Virtual to physical address 4
Background image of page 4
Mapping from a Virtual to a Physical Address 12 bits 20 bits 4KB page size 12 bits Page offset Virtual page # Virtual address: 2 bits GB address space 32 bits 4GB address space Page table = hysical address: age offset hysical page # Physical address: 512MB physical memory 29 bits Page offset Physical page # 17 bits 12 bits 5
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
How to Find a Page: Page Table 6
Background image of page 6
Page Table (cont.) Virtual address Page table register Page offset Virtual page number 20 12 31 30 29 28 27 15 14 13 12 11 10 9 8 3 2 1 0 Physical page number Valid Page table If 0 then page is not present in memory 18 29 28 27 13 12 11 10 9 8 3 2 1 0 7
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Page Fault ± If the valid bit for a virtual page is off, a page fault occurs. Page fault n exception handler is invoked to handle the page fault 8 An exception handler is invoked to handle the page fault • Find the page in the disk, fetch it, replace a page in the main memory if there is no free page in the main memory
Background image of page 8
Key Decisions in Paging ± Huge miss penalty: a page fault may take millions of cycles to process – Pages should be fairly large (e.g., 4KB) to amortize the high access time – Reducing page faults is important • LRU replacement is worth the price • fully associative placement => use page table (in memory ) to locate pages – Handle the faults in software instead of hardware, because handling time is small compared to disk access • the software can be very smart or complex • the faulting process can be context-switched – Using write-through is too expensive, so we use write back 9
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Page Replacement: 1-bit LRU ± Associated with each page is a reference bit (use bit) : Ref. bit = 1
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 47

Lecture_12_virtual_memory.pdf - Lecture 12 12 Virtual...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online