lec12-Replacement

lec12-Replacement - Announcement CSE120 Principles of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CSE120 Principles of Operating Systems Prof Yuanyuan (YY) Zhou Lecture 12: Page Replacement & Disks May 16, 2011 Announcement May 25 th : guest lecture by Teradata June 1st, Wednesday, Android Midterm, scheduling solution revision, talk with TA on Thursday’s discussion section if your solution matches with the correct one May 15, 2011 CSE 120 2 Review At a memory instruction Does it use a virtual address or physical address? What can happen? Best case What if you are unlucky? Demand paging What is it? Why introduces it? Page fault What is it? Why does it happen? Who handles it? How costly is it? May 15, 2011 CSE 120 3 5/15/2011 CS 323 - Operating Systems, Yuanyuan Zhou 4 Demand Paging Algorithm Algorithm Never bring a page into primary memory until its needed. 1. Page fault 2. Check if a valid virtual memory address. Kill job if not. 3. If valid reference, check if its cached in memory already (perhaps for some other process.) If so, skip to 7). 4. Find a free page frame. If no free page available, choose one to evict 4a. If the victim page is dirty, write it out to disk first 5. Suspend user process, Map address into disk block and fetch disk block into page frame. . 6. When disk read finished, add vm mapping for page frame. 7. If necessary, restart process.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 May 15, 2011 CSE 120 – Lecture 11 – Page Replacement 5 Demand Paging (detail) Some Pages are evicted to disk when memory is full Pages loaded from disk when referenced again References to evicted pages cause a TLB miss PTE was invalid, causes fault OS allocates a page frame, reads page from disk When I/O completes, the OS fills in PTE, marks it valid, and restarts faulting process Dirty vs. clean pages Actually, only dirty pages (modified) need to be written to disk Clean pages do not – but you need to know where on disk to read them from again 5/15/2011 CS 323 - Operating Systems, Yuanyuan Zhou 6 Page Replacement 1. Find location of page on disk 2. Find a free page frame 1. If free page frame use it 2. Otherwise, select a page frame using the page replacement algorithm 3. Write the selected page to the disk and update any necessary tables 3. Read the requested page from the disk. 4. Restart the user process. 5. It is necessary to be careful of synchronization problems. For example, page faults may occur for pages being paged out. May 15, 2011 CSE 120 7 Issue: Eviction Hopefully, kick out a less-useful page Dirty pages require writing, clean pages don’t Hardware has a dirty bit for each page frame indicating this page has been updated or not Where do you write? To “swap space” Goal: kick out the page that’s least useful Problem: how do you determine utility? Kick out pages that aren’t likely to be used again
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/26/2012 for the course CSE 120 taught by Professor Staff during the Spring '08 term at UCSD.

Page1 / 11

lec12-Replacement - Announcement CSE120 Principles of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online