DOC PREVIEW
Stanford CS 140 - Midterm Statistics

This preview shows page 1-2-3-4-5 out of 15 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 15 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 15 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 15 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 15 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 15 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 15 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Midterm StatisticsCS 140 Project 3 Virtual MemoryOverviewVirtual MemoryPagingPage Table (1)Page Table (2)Page Fault!Swap DiskProject RequirementMore at Page FaultMemory Mapped FilesTo pass more tests…Useful FunctionsQuestions?Midterm Statistics024681012141618< 49 50 60 70 80 90 100Average: 75Median: 77 Std Dev:18Maximum: 100CS 140 Project 3Virtual MemoryChia-Hui TaiCS140 Autumn 07-08Stanford UniversitySome slides are adapted from Ben Sapp 2007Overview• Typical OS structureP1P2 P3 P4UserKerneldriver driver driverNetwork Console DiskVirtual MemoryIPCFile SystemSocketTCP/IPCPUSchedulerSystem CallAdopted from Lecture Notes L1 p.14Virtual MemoryStackUn-initialized DataInitialized DataCode SegmentKernel SpaceStackUn-initialized DataInitialized DataCode SegmentupagekpagePhysical MemoryframePHYS_BASEPaging• Users think that they have the whole memory space– Let them think that way– Load in their stuff only when they need it• Not enough space? Remove others’– Which one to remove?– Where does the removed one go?Manage a “Frame Table” and a “Swap Table” for that…Page Table (1)• Original in pintos– From upage to frame / kpagee.g. user wants a new upage at vaddr:• palloc_get_page(PAL_USER) returns a kpage•Register vaddr <=> kpage with pagedir_set_page()• User accesses the mem space at kpage via vaddr– Is this page accessed before?• read => pagedir_is_accessed() == true • written => pagedir_is_dirty() == true– pagedir.c, Ref manual A.6, A.7Page Table (2)• Now with paging– upage might not be in physical memory• How do we know if it is or not?• If not, then where is the user page?– Supplemental Page Table• Data structure• Who uses this table?– Page fault handler– Process terminationPage Fault!• What’s going on?– What’s the faulting virtual addr? Is it valid?– Which page contains this addr?– Is the data in swap or filesys? Where exactly?– No space to bring in the page from swap?• Evict others’ page! Which?– Or, a request for stack growth?– If obtain a new frame, don’t forget to registerSwap Disk• You may use the disk on interface hd1:1 as the swap disk (see devices/disk.h)• From vm/build– pintos-mkdisk swap.dsk n, to create an n MB swap disk named swap.dsk– Alternatively, create a temporary n-MB swap disk for a single run with --swap-disk=n.• Disk interface easy to use, for example: struct disk swap_disk = disk_get(1,1);disk_read(swap_disk,sector,buffer);disk_write(swap_disk,sector,buffer);• Maintain free slots in swap disk. Data structure?Project Requirement Page Table Management Page fault handling virtual to physical mapping Paging to and from (swap) disk implement eviction policies Lazy Loading of Executables Stack Growth Memory Mapped FilesEasy extensions oncehave paging infrastructureMore at Page Fault• Lazy Loading of Exec– Only bring program pages when needed– Any benefit?– On eviction?• Stack Growth– Page faults on an address that "appears" to be a stack access, allocate another stack page• How to you tell if it is a stack access?– First stack page can still be loaded at process load time (in order to get arguments, etc.)Memory Mapped Files• Example (of a user program)– Map a file called foo into your address space at address 0x10000000void *addr = (void *)0x10000000; int fd = open("foo"); mapid_t map = mmap(fd, addr);addr[0] = 'b';write(addr, 64, STDOUT_FILENO)• The entire file is mapped into consecutive virtual pages starting at addr. • Make sure addr not yet mapped, no overlapTo pass more tests…• Synchronization– Paging Parallelism• Handle multiple page faults at the same time• Synchronize the disk• Resource Deallocation– Free allocated resources on termination• Pages•Locks• Your various tables• OthersUseful Functions•uintptr_tpd_no (const void *va) •uintptr_tpt_no (const void *va) • unsigned pg_ofs (const void *va) • void *pg_round_down (const void *va) • void *pg_round_up (const void *va)• bool pagedir_is_dirty (uint32_t *pd, const void *vpage) • bool pagedir_is_accessed (uint32_t *pd, const void *vpage) • void pagedir_set_dirty (uint32_t *pd, const void *vpage, bool value) • void pagedir_set_accessed (uint32_t *pd, const void *vpage, bool value)• What are they for?– Read Ref manual A5 –


View Full Document

Stanford CS 140 - Midterm Statistics

Documents in this Course
Homework

Homework

25 pages

Notes

Notes

8 pages

Load more
Download Midterm Statistics
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 Midterm Statistics 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 Midterm Statistics 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?