Other things being equal, it makes more
sense to replace a page that has not been modified, because the contents of memory don??™t need to be written to
disk as the page is replaced; nothing has been changed. On the other hand, a modified, or ???dirty,??? page will need
to be written to disk to store the changes before its memory can be reallocated.
Page Replacement Algorithms
When a process needs a page that is not yet mapped into memory, and another page must be replaced to
accommodate that, the OS must decide which page to sacrifice. Much research and experimentation have gone
into creating efficient algorithms for replacing pages in memory. As an example, we will discuss the ???clock??? or
???second chance??? algorithm.
The clock algorithm uses the Referenced bits in the page table, and a pointer into the page table. Every read
or write to a page of memory sets the Referenced bit for the page to 1. On every clock tick interrupt to the
CHAP. 6] OPERATING SYSTEMS 121
system, the OS clears the Referenced bit in every page table entry. The system also maintains a pointer, the
???clock hand,??? that points to one of the page table entries, and the system treats the page table as a circular list
of pages.
Pages:
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335