13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Page-replacement policies 1017 PAGE-REPLACEMENT POLICIESThe sum of all the virtual spaces in use by all processes may vastly exceed physical storesize. This situation certainly holds under multiprogramming, whether batch or interactive.It can even hold under a one-process regimen if the process is very large. Wheneverall of virtual space cannot fit in physical store, the storage manager must decidewhich pages should be in main store and which on backing store. Although these decisionsmay be made at any time, the storage manager is certainly forced to make a decisionwhenever a page fault occurs.The process that suffers a page fault cannot continue until the missing page isswapped in. Meanwhile, the kernel can switch to another ready process so that time isnot wasted. Typical times to swap in a page range from 20 to 50 milliseconds, duringwhich a lot of computing can take place.If free page frames are available, a newly swapped-in page may reside in any oneof them; no replacement policy is necessary. However, if all page frames are in use, apage-replacement policy must then decide which page frame to vacate by swapping outits page. The following candidates for a page to swap out come to mind:Pages that belong to processes that have terminated. These pages don’t even haveto be swapped out; their frames can be overwritten immediately.Pages that belong to processes that have been blocked a long time. They are notlikely to be needed soon.Pages that belong to ready processes but have not been accessed in a long time.We would hope that they are not needed soon.Pages that have not been modified since they were swapped in and therefore can beoverwritten without being copied back out.We would like to preserve pages that are currently enjoying heavy use.One goal of the page-replacement policy is to minimize the number of page faults.This goal follows the Cache Principle. The accesses that processes make to virtual storeshould be fast. Every page fault limits the speed of those accesses because a process thatsuffers a fault must wait until a swap is completed. Swapping can reach a level at whichall processes present need to swap, with the result that no progress can be made. If thissituation persists, the operating system thrashes, spending all its time transferring pagesin and out of main store.Page-replacement policies take the following approaches.Choose pages to swap in and out cleverly so that processes usually find the pagesthey need already in main store.If clever choice is insufficient to keep the number of page faults low, reduce thelevel of multiprogramming — that is, lower the number of processes simultaneouslycompeting for the computing resource. More main store can then be dedicatedto each process, reducing the frequency of page faults. Processes that are

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!