1 / 19

Malloc & VM

Malloc & VM. By sseshadr. Agenda. Administration 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 th ) Proxy Lab out in a week (Tuesday, November 9 th ) Plan for today

ata
Download Presentation

Malloc & VM

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Malloc & VM By sseshadr

  2. Agenda • Administration • 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) • Plan for today • Pointer declarations that I messed up • Finish malloc questions • mm_checkheap • VM

  3. Review of C Pointer Declarations(K&R section 5.12) int *p int *p[13] int *(p[13]) int **p int (*p)[13] int *f() int (*f)() int (*(*f())[13])() int (*(*x[3])())[5] p is a pointer to int p is an array[13] of pointer to int p is an array[13] of pointer to int p is a pointer to a pointer to an int p is a pointer to an array[13] of int f is a function returning a pointer to int f is a pointer to a function returning int f is a function returning ptr to an array[13] of pointers to functions returning int x is an array[3] of pointers to functions returning pointers to array[5] of ints

  4. Malloc Questions?

  5. mm_checkheap • More for YOU than for US. • But we’ll grade it. • Checks consistency of data structure • (Doubly) linked lists are pointed correctly? • Headers and footers match up? • No allocated blocks in your explicit list? • No free blocks NOT in your explicit list? • Any of YOUR OWN invariants! (address-ordering?) • Seg lists: no big chunks in small lists / vice versa?

  6. Virtual Memory

  7. Basic Concepts

  8. Basic Concepts

  9. Basic Concepts • Assumptions • n-bit virtual address • m-bit physical address • P = 2p = Page size • How big is… • The virtual page number? • The physical page number? • The virtual page offset? • The physical page offset?

  10. Basic Concepts • Assumptions • n-bit virtual address • m-bit physical address • P = 2p = Page size • How big is… • The virtual page number? (n-p) bits • The physical page number? (m-p) bits • The virtual page offset? p bits • The physical page offset? p bits

  11. 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.

  12. Basic Concepts • These addresses are stored as Page Table Entries in a Page Table. • Just a listing of conversions from VPN -> PPN • And whether it’s valid • Since memory translations happen very often, modern architectures speed this up with a TLB.

  13. Basic Concepts • Translation Lookaside Buffer • Hardware! • Is like a cache from VPNs to PPNs • During a translation, ask the TLB first by giving it an INDEX and TAG • How big is… • The index? • The tag?

  14. TLB • Translation Lookaside Buffer • Hardware! • Is like a cache from VPNs to PPNs • During a translation, ask the TLB first by giving it an INDEX and TAG • How big is… • The index? log2 (# of sets) • The tag? (n - p - index_size)

  15. 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. • TLB Miss and not in the page table • Page fault. What does the OS do? • Make some mappings? • Throw a SIGSEGV? • Kill the process?

  16. Virtual Address Anatomy • TLB has 4 sets, 14-bit VA, 64 byte pages

  17. Physical Address Anatomy • Direct-mapped cache has 16 lines, each block has 4-bytes. 12-bit PA, 64 byte pages

  18. Translation! • End-to-end translation in the book from pages 794 to 798

  19. Practice! • Lots of VM questions in past Exam 2s • Means you’re likely to see one on this test!

More Related