13.07.2015 Views

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

An Operating Systems Vade Mecum

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Page-replacement policies 109search ended. (You should be reminded of the circular first-fit technique of storage allocationfor segments.) As each page is passed, its Used field is set to false, so it is certainthat some page will eventually be chosen. Every time the storage manager rotatesthrough all the pages in the page table, it discards all pages that have not been usedrecently. NUR is occasionally called the ‘‘clock algorithm,’’ since it sweeps past eachpage frame much as a hand on a clock sweeps past each point on the circumference. TheNUR method yields a characteristic number of 95949 for our synthesized page-referencestring, only 2 percent higher than true LRU.There are many variations on this theme. We can reset the Used field to false bydifferent strategies.Don’t change Used fields to false as they are scanned when the storage manager islooking for one to swap out. Instead, reset them all to false if a scan through all thepages fails to find any that has not been used. This variant gives a characteristicnumber 97741 on the synthesized page-reference string, about 4 percent higherthan true LRU.Reset all Used fields after each page fault, after the next victim has been selected.This variant gives a characteristic number of 100604 on the synthesized pagereferencestring, about 7 percent higher than true LRU.Reset all Used fields to false on a regular schedule, say, 60 times a second.The storage manager can also increase the memory capacity of the Used field by periodicallyright-shifting it into the most significant bit of a timestamp word kept for eachpage. In this case, Used holds an integer, not a Boolean. We assume that true isrepresented by a one and false by a zero. After four such shift events, for example, wemight have the following values for four pages:Page Timestamp0 01011 00112 10013 1110The first time the storage manager shifted the Used field into the initially zero timestamps,pages 0, 1, and 2 had been referenced, but 3 had not. The next time a shift eventoccurred, pages 1 and 3 had been referenced. Pages 0 and 3 were referenced in the nextinterval, and pages 2 and 3 in the most recent interval. Based only on the highest-order(that is, most recently modified) bit of the Used field, we would select either page 0 or 1to discard next, since neither was referenced recently. The additional history that wehave retained tells us that page 1 is a better victim, since it was not used for two timeintervals. In general, the page with the smallest timestamp in the Used field is the preferredvictim.

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

Saved successfully!

Ooh no, something went wrong!