15-213 Recitation 7 Greg Reshko Office Hours: Wed 2:00-3:00PM March 31 st, 2003.

Slides:



Advertisements
Similar presentations
C SINGH, JUNE 7-8, 2010IWW 2010, ISATANBUL, TURKEY Advanced Computers Architecture, UNIT 2 Advanced Computers Architecture Virtual Memory By Rohit Khokher.
Advertisements

COMP 3221: Microprocessors and Embedded Systems Lectures 27: Virtual Memory - III Lecturer: Hui Wu Session 2, 2005 Modified.
Virtual Memory October 25, 2006 Topics Address spaces Motivations for virtual memory Address translation Accelerating translation with TLBs class16.ppt.
Carnegie Mellon 1 Virtual Memory: Concepts : Introduction to Computer Systems 15 th Lecture, Oct. 14, 2010 Instructors: Randy Bryant and Dave O’Hallaron.
CS 153 Design of Operating Systems Spring 2015
Virtual Memory Oct. 21, 2003 Topics Motivations for VM Address translation Accelerating translation with TLBs class17.ppt “The course that gives.
Virtual Memory Nov 27, 2007 Slide Source: Topics Motivations for VM Address translation Accelerating translation with TLBs class12.ppt.
Memory Management (II)
Recap. The Memory Hierarchy Increasing distance from the processor in access time L1$ L2$ Main Memory Secondary Memory Processor (Relative) size of the.
COMP 3221: Microprocessors and Embedded Systems Lectures 27: Virtual Memory - II Lecturer: Hui Wu Session 2, 2005 Modified.
Virtual Memory Topics Motivations for VM Address translation Accelerating translation with TLBs CS213.
Virtual Memory October 30, 2001 Topics Motivations for VM Address translation Accelerating translation with TLBs class19.ppt “The course that gives.
Virtual Memory October 29, 2007 Topics Address spaces Motivations for virtual memory Address translation Accelerating translation with TLBs class16.ppt.
Virtual Memory May 19, 2008 Topics Motivations for VM Address translation Accelerating translation with TLBs EECS213.
Recitation 9 (Nov. 8) Outline Virtual memory Lab 6 hints Reminders Lab 6: Get correctness points Exam 2: Nov. 16 (Next Tue) Minglong Shao
CS 241 Section Week #12 (04/22/10).
Virtual Memory Topics Motivations for VM Address translation Accelerating translation with TLBs CS 105 “Tour of the Black Holes of Computing!”
CML CML CS 230: Computer Organization and Assembly Language Aviral Shrivastava Department of Computer Science and Engineering School of Computing and Informatics.
Carnegie Mellon /18-243: Introduction to Computer Systems Instructors: Bill Nace and Gregory Kesden (c) All Rights Reserved. All work.
1 Seoul National University Virtual Memory: Systems.
1 Virtual Memory. 2 Outline Pentium/Linux Memory System Core i7 Suggested reading: 9.6, 9.7.
1 Recitation #9, Section F, , Sp 06 Virtual memory Reminders: Quiz today: virtual memory Shell Lab due Thursday TA: Jernej Barbic Modified from:
1 Virtual Memory: Concepts Andrew Case Slides adapted from Jinyang Li, Randy Bryant and Dave O’Hallaron.
Carnegie Mellon 1 Virtual Memory: Concepts Instructor: Rabi Mahapatra (TAMU) Slides: Randy Bryant and Dave O’Hallaron (CMU)
Pentium III Memory.
CSE 351 Virtual Memory. Agenda Today … Review on VM Example problems on VM accesses.
Virtual Memory March 23, 2000 Topics Motivations for VM Address translation Accelerating address translation with TLBs Pentium II/III memory system
Review (1/2) °Caches are NOT mandatory: Processor performs arithmetic Memory stores data Caches simply make data transfers go faster °Each level of memory.
1 Memory Management. 2 Fixed Partitions Legend Free Space 0k 4k 16k 64k 128k Internal fragmentation (cannot be reallocated) Divide memory into n (possible.
Virtual Memory April 3, 2001 Topics Motivations for VM Address translation Accelerating translation with TLBs class20.ppt.
University of Amsterdam Computer Systems – virtual memory Arnoud Visser 1 Computer Systems Virtual Memory.
Virtual Memory Additional Slides Slide Source: Topics Address translation Accelerating translation with TLBs class12.ppt.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Demand Paging.
Virtual Memory.  Next in memory hierarchy  Motivations:  to remove programming burdens of a small, limited amount of main memory  to allow efficient.
Carnegie Mellon 1 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Virtual Memory: Concepts Slides adapted from Bryant.
Virtual Memory : Introduction to Computer Systems Recitation 10: Oct. 28, 2013 Marjorie Carlson Recitation A.
Virtual Memory Topics Motivations for VM Address translation Accelerating translation with TLBs CS 105 “Tour of the Black Holes of Computing!”
Carnegie Mellon Introduction to Computer Systems / Spring 2009 March 23, 2009 Virtual Memory.
CS 105 “Tour of the Black Holes of Computing!”
Virtual Memory Topics Motivations for VM Address translation Accelerating translation with TLBs VM1 CS 105 “Tour of the Black Holes of Computing!”
Memory Management Continued Questions answered in this lecture: What is paging? How can segmentation and paging be combined? How can one speed up address.
1 Virtual Memory. 2 Outline Virtual Space Address translation Accelerating translation –with a TLB –Multilevel page tables Different points of view Suggested.
Carnegie Mellon 1 Bryant and O’Hallaron, Computer Systems: A Programmer’s Perspective, Third Edition Virtual Memory: Systems CSCE312: Computer Organization.
University of Washington Indirection in Virtual Memory 1 Each process gets its own private virtual address space Solves the previous problems Physical.
1 Virtual Memory. 2 Outline Case analysis –Pentium/Linux Memory System –Core i7 Suggested reading: 9.7.
Translation Lookaside Buffer
Virtual Memory: Systems
Today How was the midterm review? Lab4 due today.
Virtual Memory.
CS 105 “Tour of the Black Holes of Computing!”
Memory Hierarchy Virtual Memory, Address Translation
CSE 153 Design of Operating Systems Winter 2018
Virtual Memory: Systems /18-213/14-513/15-513: Introduction to Computer Systems 18th Lecture, October 25, 2018.
CS 105 “Tour of the Black Holes of Computing!”
Virtual Memory: Concepts /18-213/14-513/15-513: Introduction to Computer Systems 17th Lecture, October 23, 2018.
Virtual Memory: Systems
Virtual Memory: Systems
Virtual Memory S04, Recitation, Section A
Page that info back into your memory!
Virtual Memory CSCI 380: Operating Systems Lecture #7 -- Review and Lab Suggestions William Killian.
Translation Lookaside Buffer
Instructors: Majd Sakr and Khaled Harras
Virtual Memory Nov 27, 2007 Slide Source:
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
Virtual Memory II CSE 351 Winter 2018
CSE 451: Operating Systems Autumn 2003 Lecture 10 Paging & TLBs
CSCI 380: Operating Systems William Killian
CS703 - Advanced Operating Systems
CSE 153 Design of Operating Systems Winter 2019
Instructor: Phil Gibbons
Presentation transcript:

Recitation 7 Greg Reshko Office Hours: Wed 2:00-3:00PM March 31 st, 2003

Outline Virtual Memory  Paging  Page faults  TLB  Address translation Malloc Lab  Lots of hints and ideas

Virtual Memory Reasons  Use RAM as a cache for disk  Easier memory management  Protection  Enable ‘partial swapping’  Share memory efficiently

Physical memory CPU 0: 1: N-1: Memory Physical Addresses

Virtual Memory CPU 0: 1: N-1: Memory 0: 1: P-1: Page Table Disk Virtual Addresses Physical Addresses

Paging: Purpose Solves two problems  External memory fragmentation  Long delay to swap a whole process Divide memory more finely  Page – small logical memory region  Frame – small physical memory region Any page can map to any frame

Paging: Address Mapping Logical Address PageOffset.... f29 f FrameOffset Page table Physical Address

Paging: Multi-Level P1Offset.... f29 f34 f25 FrameOffset Page Tables.... f99 f P2.... f07 f Page Directory

Page Faults Virtual address not in memory  This means it is on a disk  Go to disk, fetch the page, load it into memory, get back to the process CPU Memory Page Table Disk Virtual Addresses Physical Addresses CPU Memory Page Table Disk Virtual Addresses Physical Addresses

Copy-on-Write “Simulated” Copy  Copy page table entries to new process  Mark PTEs read-only in old and new What really happens  Process writes to page  Page fault handler is called Copy page into empty frame Mark read-write in both PTEs Result  Faster and less work

Relevance to Fork Why is paging good for fork and exec?  Fork produces two very similar processes Same code, data, and stack  Copying all pages is expensive Many will never be modified (especially in exec)  Share pages instead i.e. just mark them as read only and duplicate when necessary

Address Translation: General Idea Mapping between virtual and physical addresses Processor Hardware Addr Trans Mechanism fault handler Main Memory Secondary memory V P  page fault physical address OS performs this transfer (only if miss) virtual addresspart of the on-chip memory mgmt unit (MMU)

Address Translation: In terms of address itself Higher bits of the address get mapped from virtual address to physical. Lower bits (page offset) stays the same. virtual page numberpage offset virtual address physical page numberpage offset physical address 0p–1 address translation pm–1 n–1 0p–1p

TLB Translation Lookaside Buffer  Small hardware cache in MMU  Maps virtual page numbers to physical page numbers CPU TLB Lookup Cache Main Memory VAPA miss hit data Trans- lation hit miss

... Address Translation with TLB virtual address virtual page number page offset physical address n–10p–1p validphysical page numbertag validtagdata = cache hit tagbyte offset index = TLB hit TLB Cache

Example Motivation:  A detailed example of end-to-end address translation  Same as in the book and lecture I just want to make sure it makes perfect sense  Do practice problems at home Ask questions if anything is unclear

Example: Description Memory is byte addressable Accesses are to 1-byte words Virtual addresses are 14 bits Physical addresses are 12 bits Page size is 64 bytes TLB is 4-way set associative with 16 total entries L1 d-cache is physically addressed and direct mapped, with 4-byte line size and 16 total sets

Example: Addresses VPO PPOPPN VPN (Virtual Page Number) (Virtual Page Offset) (Physical Page Number) (Physical Page Offset) 14-bit virtual addresses 12-bit physical address Page size = 64 bits

Example: Page Table VPNPPNValid – – –0 07–0 VPNPPNValid A091 0B–0 0C–0 0D2D1 0E111 0F0D1 …

Example: TLB 16 entries 4-way associative VPO VPN TLBI TLBT SetTagPPNValidTagPPNValidTagPPNValidTagPPNValid 003–0090D100– D102–004–00A–0 202–008–006–003–0 307–0030D10A34102–0

Example: Cache 16 lines 4-byte line size Direct mapped PPOPPN CO CI CT IndexTagValidB0B1B2B3IndexTagValidB0B1B2B A ––––92D0–––– 21B A2D19315DA3B 3360––––B0B0–––– D8F09C120–––– 50D13672F01DD ––––E BD C2DF03F140––––

Example: Address Translation Virtual Address 0x03D4 Split into offset and page number  0x03D4 =  VPO = = 0x14  VPN = = 0x0F Lets see if this is in TLB  0x03D4 =  TLBI = 11 = 0x03  TLBT = = 0x03

Example: TLB 16 entries 4-way associative VPO VPN TLBI TLBT SetTagPPNValidTagPPNValidTagPPNValidTagPPNValid 003–0090D100– D102–004–00A–0 202–008–006–003–0 307–0030D10A34102–0

Example: Address Translation Virtual Address 0x03D4 TLB lookup  This address is in TLB (second entry, set 0x3)  PPN = 0x0D =  PPO = VPO = 0x14 =  PA = PPN + PPO = Cache  PA = 0x354 = 0x  CT = = 0x0D  CI = 0101 = 0x05  CO = 00 = 0x0

Example: Cache 16 lines 4-byte line size Direct mapped PPOPPN CO CI CT IndexTagValidB0B1B2B3IndexTagValidB0B1B2B A ––––92D0–––– 21B A2D19315DA3B 3360––––B0B0–––– D8F09C120–––– 50D13672F01DD ––––E BD C2DF03F140––––

Example: Address Translation Virtual Address 0x03D4 Cache Hit  Tag in set 0x5 matches CT  Data at offset CO is 0x36  Data returned to MMU  Data returned to CPU

Lab 6 Hints and Ideas Due April points for performance 20 points for correctness 5 points for style Get the correctness points this week  Get a feel for how hard the lab is  You'll probably need the time  Starting a couple days before is a BAD idea!

How to get the correctness points We provide mm-helper.c which contains the code from the book  malloc works  free works (with coalescing)  Heap checking doesn't work  realloc doesn't work Implement a dumb version of realloc  malloc new block, memcpy, free old block, return new block

How to get the correctness points Implement heap checking  Have to add a request id field to each allocated block (tricky)  Hint: need padding to maintain 8 byte alignment of user pointer  In the book's code bp always the same as the user pointer The 4 bytes immediately before bp contain size of payload 3 lsb of size unused (because of alignment)  first bit indicates of the block is alloced or not Size+aPayload…Footer bp

How to get the correctness points Need to change block layout to look like this: This changes how the implicit list has to be traversed  But size is at same place relative to bp Size+aPayload…Footer bp ID

How to get the correctness points Or change block layout to look like this: All accesses to what was size now access id but can be clever and make size 4 bytes larger Could even make bp point to id.. Most code would just work IDPayload…Footer bp Size+a

How to get the correctness points Once malloc, free, and realloc work with the id field, write heapcheck  Iterate over the whole heap and print out allocated blocks  Need to read the id field… That's it for correctness

Hints Remember that pointer arithematic behaves differently depending on type of pointer Consider using structs/unions to eliminate some messy pointer code Get things working with the short trace file first:./mdriver -f short1-bal.rep To get the best performance  Red-Black trees  Ternary trees  Other interesting data structures

That’s it for hints… Good Luck!