1 / 14

Paging with Multiprogramming

Paging with Multiprogramming. CS 537 - Introduction to Operating Systems. Global Allocation. Processes compete for pages against one another Allows a process to use as many pages as it needs if one is using 10 pages and another a 100, memory is allocated efficiently

kirby
Download Presentation

Paging with Multiprogramming

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. Paging with Multiprogramming CS 537 - Introduction to Operating Systems

  2. Global Allocation • Processes compete for pages against one another • Allows a process to use as many pages as it needs • if one is using 10 pages and another a 100, memory is allocated efficiently • if a processes changes from using 10 to using 100 pages, its new state can be met

  3. Global Allocation • Problem if one page is a memory “hog” • imagine database program that is just searching and another process that is only using a few pages • the database program will “steal” all of the pages even though it’s not really using them • A process may perform differently from one run to the next because of external factors • first time it runs with “good” processes • next time it runs with a “hog”

  4. Local Allocation • Assign a certain number of pages to each process to use for paging • Can base this number on needs of process • a larger process can be allocated more frames • This prevents memory “hog” problem • What if a process doesn’t need all of its frames? • another process that could use them won’t get them

  5. Virtual Time • Give each process its own clock • Last reference of a page is based on the clock of the process that is using the page • not on a global time • Using this, a process’s pages are not punished because the process is context switched out

  6. Virtual Time • Keep the clock for a process in its PCB • start(p) • PCB[p].lastStart = now • stop(p) • PCB[p].virtualTime += now - PCB.lastStart

  7. Working Set • Minimum number of pages a process needs in memory to execute satisfactorily fit working set in memory page rate # of frames • W(p) = set of pages process p touched during the last  seconds of virtual time

  8. Thrashing • If a processes working set is not in memory, the process will thrash • Process spends most of its time reading in pages from disk • Virtually no useful work will get done • Better to kill a process than to let it thrash

  9. Working Set Size • How many pages make up the working set of a process? • measure each process carefully • requires running the process before hand • requires process behave the same way • ask the user • requires a user to be truthful • monitor the process • Page fault frequency monitoring • clock algorithm

  10. Page Fault Frequency • Give each process initial number of pages • If process page faults are above a set threshold • give the process a new frame • If process page faults are below a set threshold • take away a frame from the process • If all of the process have too high of a page fault rate • kill some process

  11. Clock Algorithm • Use clock algorithm discussed before for doing replacement • modified slightly • If the “hand” is moving too fast, kill some process • If the “hand” is moving slowly enough, start some process

  12. Clock Algorithm • Some terminology • VT(p) = virtual time of a process • LR[f] = time of last reference to a frame • based on virtual time of owner process • owner[f] = process that owns a frame • PT[f] = page table entry for a frame

  13. VT(p) - LR[f] >  Clock Algorithm f = (f+1) % memSize; // move hand forward if(full revolution of hand w/o finding a page) deactivate some process R = PT[f].refBit; PT[f].refBit = 0; p = owner[f]; second chance 1 R LR[f] = VT(p) 0 third chance no yes is p active? yes no 1 replace frame f 0 PT[f].dirty clean(f)

  14. Clock Algorithm • Allows a process’s frame ownership to grow • A page is only taken away from a process if the process hasn’t used it for a long time

More Related