1 / 6

Problem 3.2 Paging Algorithms-Time & Space Requirements

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.

kana
Download Presentation

Problem 3.2 Paging Algorithms-Time & Space Requirements

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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. LRU Block LFU Block New reference New reference heap MRU Block MFU Block Problem 3.2 Paging Algorithms-Time & Space Requirements k is the fast memory size, and l is the length of request sequence • LRU Replacement • LFU Replacement T: O(log k) complexity Total: O(llogk), l is the length of request sequence. S: O(klog(n)) T: O(1) complexity Total: O(l), l is the length of request sequence. S: O(klogk) O(n) complexity

  3. Shortest forward distance Longest forward distance Problem 3.2 Paging Algorithms-Time & Space Requirements • LIFO Replacement • LFD Replacement Latest page id 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)

  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)

More Related