Lecture 2 Flashcards
(23 cards)
How does the clock replacement algorithm try to implement LRU?
Try to achieve some of the benefits of LRU replacement, but without the computational overhead of LRU.
How does the clock replacement algorithm approximate LRU?
Uses a reference bit. This reference bit corresponds to a used bit that is set for each page reference.
What does it mean if the used bit is not set?
The corresponding page has not been referenced in a long time.
Where is the used bit for each page usually stored?
Page table or Translation Look-aside Buffer(T LB)
What makes the used bit fast to access and modify?
It is just one bit, stored in cache memory
What are the three states the clock replacement algorithm assumes a page can be in when a page reference occurs?
- Page not in memory
- Used-bit = 0, Page in memory but not recently used.
- Used bit = 1, Page in memory and recently used.
Is it possible to have a page fault when used bit set to 1?
No, no page fault will occur when the page is being accessed.
What happens when page fault occurs when used bit = 0?
Bit is changed to 1 (recently used).
How can a page fault occur when used bit = 0?
The page is not in main memory but being temporarily stored in the translation look aside buffer (TLB).
Which pages does the clock replacement algorithm end up replacing?
The clock algorithm thus replaces pages that have not been referenced for one complete revolution of the page pointer.
How are the physical page frames in the clock algorithm arranged in a circle?
With a circular linked list.
What is the goal of the clock algorithm?
Replace pages that are old enough and not necessarily the oldest
How does the clock algorithm store pages?
In circular linked list, with one reference bit per page.
What happens when the clock algorithm encounters a page with the reference bit set?
Set its reference bit to 0,and advance the clock pointer to the next page.
Best case and worst case of clock replacement algorithm.
Best - First page has reference bit cleared and is replaced.
Worst - All pages have reference bit set, clock has to loop around entire list and replace the page where the pointer started.
Advantage of the Clock replacement algorithm?
Maintains only one reference bit for each page, so it is fast and efficient.
Disadvantage of Clock replacement algorithm?
reference bit only indicates if page was used at all since last checked and not how long it has been since last used.
How to get around disadvantage of the Clock replacement algorithm?
Have extra reference bits associated with each page.
At each page reference, increment a 8−bit reference for each page to reflect how old a page is, where a page fault, the oldest page is replaced
Disadvantage with 8-bit reference strategy?
A page fault will require a search through all the pages in the linked list,in order to be sure that the oldest page is replaced.
Clock-hand moving slowly.
pointer passes few pages before a page is replaced. Many page faults, fewer reference bits set.
Clock-hand moving fast.
Pointer passes many pages before a page is replaced.
Few page faults.
Reference bits set.
Dirty Page
A page which is modified in a buffer cache (between swap-out from secondary storage and swap-in to a main memory frame).
Corresponding Dirty bit set in page table.
What happens when dirty page is replaced?
Must be written to disk (e.g. hard-drive secondary storage) before its page frame is reused.