Malloc & VM Malloc & VM By sseshadr Agenda Agenda - - PowerPoint PPT Presentation

malloc vm malloc vm
SMART_READER_LITE
LIVE PREVIEW

Malloc & VM Malloc & VM By sseshadr Agenda Agenda - - PowerPoint PPT Presentation

Malloc & VM Malloc & VM By sseshadr Agenda Agenda Administration d st at o Process lab code will be inked by Thursday (pick up in ECE hub) Malloc due soon (Thursday, November 4 th ) Exam 2 in a week (Tuesday, November 9


slide-1
SLIDE 1

Malloc & VM Malloc & VM

By sseshadr

slide-2
SLIDE 2

Agenda Agenda

  • Administration

d st at o

– Process lab code will be inked by Thursday (pick up in ECE hub) – Malloc due soon (Thursday, November 4th) – Exam 2 in a week (Tuesday, November 9th) Proxy Lab out in a week (Tuesday November 9th) – Proxy Lab out in a week (Tuesday, November 9th)

  • Plan for today

Finish malloc questions – Finish malloc questions – mm_checkheap – VM VM

slide-3
SLIDE 3

Malloc Malloc

Questions?

slide-4
SLIDE 4

mm checkheap mm_checkheap

  • More for YOU than for US.

More for YOU than for US.

– But we’ll grade it.

  • Checks consistency of data structure

Checks consistency of data structure

– (Doubly) linked lists are pointed correctly? – Headers and footers match up? Headers and footers match up? – No allocated blocks in your explicit list? – No free blocks NOT in your explicit list? y p – Any of YOUR OWN invariants! (address‐ordering?) – Seg lists: no big chunks in small lists / vice versa? g g

slide-5
SLIDE 5

Virtual Memory Virtual Memory

slide-6
SLIDE 6

Basic Concepts Basic Concepts

slide-7
SLIDE 7

Basic Concepts Basic Concepts

slide-8
SLIDE 8

Basic Concepts Basic Concepts

  • Assumptions

Assumptions

– n‐bit virtual address – m‐bit physical address p y – P = 2p = Page size

  • How big is…

How big is…

– The virtual page number? – The physical page number? p y p g – The virtual page offset? – The physical page offset? p y p g

slide-9
SLIDE 9

Basic Concepts Basic Concepts

  • Assumptions

Assumptions

– n‐bit virtual address – m‐bit physical address p y – P = 2p = Page size

  • How big is…

How big is…

– The virtual page number? (n‐p) bits – The physical page number? (m‐p) bits p y p g ( p) – The virtual page offset? p bits – The physical page offset? p bits p y p g p

slide-10
SLIDE 10

Basic Concepts Basic Concepts

  • Anatomy of addresses (using 14‐bit VA, 12‐bit PA, 64 byte page size)

– The VPN needs to have enough information so that the TLB can look up a PPN for it. – The PPN needs to have enough information so that the cache can look up the DATA at the given address.

slide-11
SLIDE 11

Basic Concepts Basic Concepts

  • These addresses are stored as Page Table

These addresses are stored as Page Table Entries in a Page Table.

– Just a listing of conversions from VPN > PPN – Just a listing of conversions from VPN ‐> PPN

  • And whether it’s valid
  • Since memory translations happen very often,

d hit t d thi ith modern architectures speed this up with a TLB.

slide-12
SLIDE 12

Basic Concepts Basic Concepts

  • Translation Lookaside Buffer

Translation Lookaside Buffer

– Hardware! Is like a cache from VPNs to PPNs – Is like a cache from VPNs to PPNs – During a translation, ask the TLB first by giving it an INDEX and TAG an INDEX and TAG

  • How big is…

Th i d ? – The index? – The tag?

slide-13
SLIDE 13

TLB TLB

  • Translation Lookaside Buffer

Translation Lookaside Buffer

– Hardware! Is like a cache from VPNs to PPNs – Is like a cache from VPNs to PPNs – During a translation, ask the TLB first by giving it an INDEX and TAG an INDEX and TAG

  • How big is…

Th i d ? l (# f t ) – The index? log2 (# of sets) – The tag? (n ‐ p ‐ index_size)

slide-14
SLIDE 14

TLB TLB

  • TLB Hit

– Got away with the shortcut!

  • TLB Miss

– Not necessarily a page fault! – Go check the page table, and then come back and fill in the missing spot in TLB. g p

  • TLB Miss and not in the page table

– Page fault. What does the OS do?

  • Make some mappings?
  • Throw a SIGSEGV?
  • Kill the process?
slide-15
SLIDE 15

Virtual Address Anatomy Virtual Address Anatomy

  • TLB has 4 sets 14‐bit VA 64 byte pages

TLB has 4 sets, 14 bit VA, 64 byte pages

slide-16
SLIDE 16

Physical Address Anatomy Physical Address Anatomy

  • Direct‐mapped cache has 16 lines each block

Direct mapped cache has 16 lines, each block has 4‐bytes. 12‐bit PA, 64 byte pages

slide-17
SLIDE 17

Translation! Translation!

  • End‐to‐end translation in the book from pages

End to end translation in the book from pages 794 to 798

slide-18
SLIDE 18

Practice! Practice!

  • Lots of VM questions in past Exam 2s

Lots of VM questions in past Exam 2s

– Means you’re likely to see one on this test!