1 / 21

CMSC421: Principles of Operating Systems

CMSC421: Principles of Operating Systems. Nilanjan Banerjee. Assistant Professor, University of Maryland Baltimore County nilanb@umbc.edu http://www.csee.umbc.edu/~nilanb/teaching/421/. Principles of Operating Systems

fox
Download Presentation

CMSC421: Principles of Operating Systems

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. CMSC421: Principles of Operating Systems Nilanjan Banerjee Assistant Professor, University of Maryland Baltimore County nilanb@umbc.edu http://www.csee.umbc.edu/~nilanb/teaching/421/ Principles of Operating Systems Acknowledgments: Some of the slides are adapted from Prof. Mark Corner and Prof. Emery Berger’s OS course at Umass Amherst

  2. Announcements • Midterm (29th of October in class) • Project 2design document is due 26th October • We will do a review at the end of the class

  3. How does all of this work? • A process asks for memory to read/write/copy • Does not really care where the data came from • Registers, L1, L2, L3, Main memory, Network memory or the disk • Key question: How do we make this transparent from the process

  4. Virtual vs. Physical Memory • Processes don’t access physical memory • Well, not directly • Apps use virtual memory • Addresses start at 0 • One level of indirection • Address you see is not “real” address

  5. Memory Pages • Programs use memory as individual bytes • OS manages groups of bytes: pages • typically 4kB, 8kB • Applies this to virtual and physical memory • Physical pages usually called frames A

  6. Mapping Virtual to Physical

  7. Why Virtual Memory? • Why? • Simpler • Everyone gets illusion of whole address space • Isolation • Every process protected from every other • Optimization • Reduces space requirements

  8. Memory Management Unit • Programs issue loads and stores • What kind of addresses are these? • MMU Translates virtual to physical addresses • Maintains page table (big hash table): • Almost always in HW… Why? MMU Program Memory Virtual Address Physical Address Page Table

  9. Page Tables • Table of translations • virtual pages -> physical pages • One page table per process • One page table entry per virtual page • How? • Programs issue virtual address • Find virtual page (how?) • Lookup physical page, add offset

  10. Page Table Entries • Do all virtual pages -> physical page? • Valid and Invalid bits • PTEs have lots of other information • For instance some pages can only be read

  11. Address Translation • Powers of 2: • Virtual address space: size 2^m • Page size 2^n • Page#: High m-n bits of virtual address • Lower n bits select offset in page • Lets take an example 11

  12. Paging Hardware 12

  13. Quick Activity • How much mem does a page table need? • 4kB pages, 32 bit address space • page table entry (PTE) uses 4 bytes • 2^32/2^12*4=2^22 bytes=4MB • Is this a problem? • Isn’t this per process? • What about a 64 bit address space? • Any ideas how to fix this?

  14. Locality • Most programs obey 90/10 “rule” • 90% of time spent accessing 10% of memory • Exploit this rule: • Only keep “live” parts of process in memory A A B B 14

  15. Multi-Level Page Tables • Use a multi-level page table A A Level 0 Table Level 1 Table A Level 1 Table

  16. Quick Activity • How much mem does a page table need? • 4kB pages, 32 bit address space • Two level page table • 20bits = 10 bits each level • page table entry (PTE) uses 4 bytes • Only first page of program is valid • 2^10*4+2^10*4=2^13 bytes=8kB • Isn’t this slow?

  17. Translation Lookaside Buffer (TLB) • TLB: fast, fully associative memory • Caches page table entries • Stores page numbers (key) and frame (value) in which they are stored • Assumption: locality of reference • Locality in memory accesses =locality in address translation • TLB sizes: 8 to 2048 entries • Powers of 2 simplifies translationof virtual to physical addresses

  18. Linear Address in Linux • Uses a three-level paging strategy that works well for 32-bit and 64-bit systems • Linear address broken into four parts:

  19. Three-level Paging in Linux

  20. Paging 20

  21. Midterm review

More Related