Download presentation
Presentation is loading. Please wait.
Published byClifford Turner Modified over 9 years ago
1
Problem 3.2 Paging Algorithms-Time & Space Requirements Problem:What are the space and time requirements of LIFO, LFU, and LED? LRU:(least-recently-used): when eviction is necessary, replace the page whose most recent request was earliest. LIFO(last-in/first-out):replace the page most recently moved to the fast memory. LFU(least-frequently-used): replace the page that has been requested the least since entering the fast memory. LFD(longest-forward-distance): replace the page whose next request is latest.
2
Problem 3.2 Paging Algorithms-Time & Space Requirements LRU ReplacementLFU Replacement LRU Block MRU Block LFU Block MFU Block New reference T: O(1) complexity Total: O(l), l is the length of request sequence. S: O(klogk) O(n) complexity heap T: O(log k) complexity Total: O(llogk), l is the length of request sequence. S: O(klog(n)) k is the fast memory size, and l is the length of request sequence
3
Problem 3.2 Paging Algorithms-Time & Space Requirements LIFO ReplacementLFD Replacement Shortest forward distance Longest forward distance T: O(1) complexity Total: O(l), l is the length of request sequence. S: O(logk) T: O(k+l+logk) complexity Total: O(l+k+logk)l, l is the length of request sequence. S: O(klogn) Latest page id
4
Problem: 3.9 Problem: Show that FWF is not a conservative algorithm. FWF: Whenever there is page fault and there is no space left in the cache, evict all pages current in the cashe. A page algorithm ALG is conservative if it satisfies the following condition: On any consecutive input subsequence containing k or fewer distinct page references, ALG will incur k or fewer page faults.
5
Problem: 3.9 (Cont.) For this exercise assume that the cache is of size k ( k >1). Otherwise the claim is not true: for example, suppose that we have a cache of size 1, and the following sequences: 1; 2; 1;2; Then, in that sequence of 4 requests there are only 2 distinct requests, yet with a cache of size 1, there would be 4 faults, for any page-replacement algorithm.
6
Problem: 3.9 (Cont.) The main idea to prove FWF is not a conservative algorithm if we can find a subsequence with k distinct pages and FWF incurs more than k page faults. For FIFO, LRU, each distinct page request can only cause one fault. Same goes for FIFO. Thus, they are both conservative algorithms. However, It is possible that half-way through the consecutive subsequence, the cache of FWF is going to get full, and FWF is going to evict everybody. Hence, FWF may have more than one page fault on the same page during this consecutive subsequence. Therefore, FWF is not a conservative algorithm. For example, k = 3; 1; 2; 3; 4;2;3;4 Subsequence: 2;3;4;2 ( 3 distinct requests, 4 faults)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.