DOC PREVIEW
CORNELL CS 3410 - Lecture Notes

This preview shows page 1-2-3-22-23-24-44-45-46 out of 46 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 46 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1AnnouncementsGoals for TodaySlide 4Address TranslationAddress TranslationSimple PageTableSummaryPage Size ExampleInvalid PagesBeyond Flat Page TablesPage PermissionsAliasingSlide 14PagingPagingSlide 17sbrkContext SwitchShared MemoryMultiplexingPaging Assumption 1Reasons for ThrashingThrashingPaging Assumption 2More ThrashingPreventing ThrashingSlide 28PerformancePage Table ReviewPage Table ExamplePerformanceSlide 33Translation Lookaside Buffer (TLB)TLB DiagramA TLB in the Memory HierarchyTLB CoherencyTranslation Lookaside Buffers (TLBs)TLB ParametersSlide 40Virtually Addressed CachingVirtual vs. Physical CachesIndexing vs. TaggingTypical Cache SetupCaches/TLBs/VMSummary of Cache Design ParametersVirtual Memory 2Hakim WeatherspoonCS 3410, Spring 2011Computer ScienceCornell UniversityP & H Chapter 5.4-52AnnouncementsPA3 available. Due Tuesday, April 19th•Work with pairs•Be responsible with new knowledge•Scheduling a games night, possibly Friday, April 22nd Next five weeks•One homeworks and two projects•Prelim2 will be Thursday, April 28th •PA4 will be final project (no final exam)3Goals for TodayVirtual Memory•Address Translation•Pages, page tables, and memory mgmt unit•Paging•Role of Operating System•Context switches, working set, shared memory•Performance•How slow is it•Making virtual memory fast•Translation lookaside buffer (TLB)•Virtual Memory Meets Caching4Address TranslationPages, Page Tables, and the Memory Management Unit (MMU)5Address TranslationAttempt #1: How does MMU translate addresses? paddr = PageTable[vaddr];Granularity?•Per word…•Per block…•Variable..…Typical:•4KB – 16KB pages•4MB – 256MB jumbo pages6Address TranslationAttempt #1: For any access to virtual address:•Calculate virtual page number and page offset•Lookup physical page number at PageTable[vpn]•Calculate physical address as ppn:offsetvaddrPage OffsetVirtual page numberPage offsetPhysical page numberLookup in PageTablepaddr7Simple PageTableQ: Where to store page tables?A: In memory, of course…Special page table base register(CR3:PTBR on x86)(Cop0:ContextRegister on MIPS)CPU MMUDataRead Mem[0x00201538]0x000000000x900000000x100450000x4123B0000xC20A30008Summaryvpn pgoffPhysical Page Number0x10045 0xC20A30x4123B0x000000x20340vaddrPTBR9Page Size ExampleOverhead for VM Attempt #1 (example)Virtual address space (for each process):•total memory: 232 bytes = 4GB•page size: 212 bytes = 4KB•entries in PageTable?•size of PageTable?Physical address space:•total memory: 229 bytes = 512MB•overhead for 10 processes?10Invalid PagesCool Trick #1: Don’t map all pages Need valid bit for each page table entryQ: Why?VPhysical Page Number01 0x10045001 0xC20A31 0x4123B1 0x0000000x000000000x900000000x100450000x4123B0000xC20A300011Beyond Flat Page TablesAssume most of PageTable is emptyHow to translate addresses? 10 bitsPTBR10 bits 10 bitsvaddrPDEntryPage DirectoryPage TablePTEntryPageWord2Multi-level PageTable* x86 does exactly this12Page PermissionsCool Trick #2: Page permissions!Keep R, W, X permission bits for each page table entryQ: Why?V R W XPhysical Page Number01 0x10045001 0xC20A31 0x4123B1 0x0000000x000000000x900000000x100450000x4123B0000xC20A300013AliasingCool Trick #3: AliasingMap the same physical pageat several virtual addressesQ: Why?V R W XPhysical Page Number01 0xC20A3001 0xC20A31 0x4123B1 0x0000000x000000000x900000000x100450000x4123B0000xC20A300014Paging15PagingCan we run process larger than physical memory?•The “virtual” in “virtual memory”View memory as a “cache” for secondary storage•Swap memory pages out to disk when not in use•Page them back in when neededAssumes Temporal/Spatial Locality•Pages used recently most likely to be used again soon16PagingCool Trick #4: Paging/SwappingNeed more bits:Dirty, RecentlyUsed, …V R W X DPhysical Page Number0 invalid1 0 0x100450 invalid0 invalid0 0 disk sector 2000 0 disk sector 251 1 0x000000 invalid0x000000000x900000000x100450000x4123B0000xC20A30002520017Role of the Operating SystemContext switches, working set, shared memory18sbrkSuppose Firefox needs a new page of memory(1) Invoke the Operating Systemvoid *sbrk(int nbytes);(2) OS finds a free page of physical memory•clear the page (fill with zeros)•add a new entry to Firefox’s PageTable19Context SwitchSuppose Firefox is idle, but Skype wants to run(1) Firefox invokes the Operating Systemint sleep(int nseconds);(2) OS saves Firefox’s registers, load skype’s•(more on this later)(3) OS changes the CPU’s Page Table Base Register•Cop0:ContextRegister / CR3:PDBR(4) OS returns to Skype20Shared MemorySuppose Firefox and Skype want to share data(1) OS finds a free page of physical memory•clear the page (fill with zeros)•add a new entry to Firefox’s PageTable•add a new entry to Skype’s PageTable–can be same or different vaddr–can be same or different page permissions21MultiplexingSuppose Skype needs a new page of memory, but Firefox is hogging it all(1) Invoke the Operating Systemvoid *sbrk(int nbytes);(2) OS can’t find a free page of physical memory•Pick a page from Firefox instead (or other process)(3) If page table entry has dirty bit set…•Copy the page contents to disk(4) Mark Firefox’s page table entry as “on disk”•Firefox will fault if it tries to access the page(5) Give the newly freed physical page to Skype•clear the page (fill with zeros)•add a new entry to Skyps’s PageTable22Paging Assumption 1OS multiplexes physical memory among processes•assumption # 1: processes use only a few pages at a time•working set = set of process’s recently actively pages# recentaccesses0x00000000 0x9000000023Reasons for ThrashingQ: What if working set is too large?Case 1: Single process using too many pagesCase 2: Too many processesworking setmem diskswappedP1working setmem diskswappedwsmem diskws ws ws ws ws24ThrashingThrashing b/c working set of process (or processes) greater than physical memory available–Firefox steals page from Skype–Skype steals page from Firefox•I/O (disk activity) at 100% utilization–But no useful work is getting doneIdeal: Size of disk, speed of memory (or cache)Non-ideal: Speed of disk25Paging Assumption 2OS multiplexes physical memory among processes•assumption # 2: recent accesses predict future accesses•working set usually changes slowly over timeworking settime 26More ThrashingQ: What if working set changes rapidly or


View Full Document

CORNELL CS 3410 - Lecture Notes

Documents in this Course
Marra

Marra

43 pages

Caches

Caches

34 pages

ALUs

ALUs

5 pages

Caches!

Caches!

54 pages

Memory

Memory

41 pages

Caches

Caches

32 pages

Caches

Caches

54 pages

Caches

Caches

34 pages

Caches

Caches

54 pages

Load more
Download Lecture Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?