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.

112 Space Management Chapter 3changes phases, the working set will contain pages that are no longer needed by the process.Luckily, w is not particularly critical; values of 0.5 second are common.To calculate the working set of a process properly would require an accurate virtualclock. Whenever a page is accessed, the current time according to that clock isrecorded in the page table. The working set contains all pages whose access time iswithin w of the present. This implementation is reminiscent of LRU, which we rejectedbecause it was too expensive.7.9 Page-fault frequency (PFF)The page-fault frequency policy employs an approximation of the working set. Itrequires only the Used fields for each page and a real-time clock. Instead of recordingthe time of each access, we make decisions about the working set only when a page faultoccurs. At that time we compare how long it has been since the previous page fault. Wewill say that the (virtual) time lag is small if it is less than p units of time, where p is atunable parameter. If the time lag is small, we will just add the new page to the workingset. If the time lag is large, we first discard all pages from the working set that have notbeen referenced since the last page fault. The new page is, of course, added to the workingset.This policy can be implemented by resetting the hardware Used field to false everytime a page fault occurs. When the next fault occurs after a long lag, all pages that stillhave a false Used field are discarded from the working set. A discarded page has itsPresent field reset to false, but it is not swapped out. Instead, the storage manager addsthat page to a pool of reasonable victims for the next time a victim must be found. If theprocess accesses that page again before it is chosen as a victim, the kernel receives amissing-page fault, removes the page from the victim pool, and brings it back into theworking set.To facilitate finding a victim, this pool of potential victims should be kept nonempty.The length of the victim list is a barometer of multiprogramming effectiveness.If the list is practically empty, too many processes are competing for physical storage,and the level of multiprogramming should be reduced. If the list is very long, it may bepossible to bring in some process that has been stranded on the main-store wait list.7.10 Working sizeThe working-size technique is another way to approximate the working set. Instead ofkeeping track of all the pages in the working set, the storage manager maintains only thesize of that set. When a process is placed in the main-store wait list, its working-set sizeis estimated by counting the number of pages it has recently accessed. This count can beperformed by examining Used fields. The process is not put back on the ready list untilthat many page frames are available for it to use.

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

Saved successfully!

Ooh no, something went wrong!