Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 5314 On-line Computation Homework 1 Wook Choi Feb/26/2004.

Similar presentations


Presentation on theme: "CSE 5314 On-line Computation Homework 1 Wook Choi Feb/26/2004."— Presentation transcript:

1 CSE 5314 On-line Computation Homework 1 Wook Choi Feb/26/2004

2 Exercise 1.9 Prove Lemma 1.1 Lemma 1.1 (Pairwise Property lemma) An algorithm satisfies the pairwise property if and only if for every request σ, when ALG servers σ, the relative order of every two elements x and y in L is the same as their relative order in L xy when ALG servers σ xy Proof using the partial cost model which does consider only the cost from negative comparisons until a requested item is found in the list: Consider any request sequence σ = r 1, r 2,, …,r n for the list L. σ xy is defined to be σ after deletion of all the requests for items except for x and y where x, y  L (x ≠ y); L xy is the projection of the list L over x and y, thus having the same initial order as in L. For each x, and integer 1 ≤ j ≤ n, the penalty cost attributed to x is denoted by ALG (x,j) in accessing j th request, r j where: Let ALG * (σ xy ) and ALG xy * (σ) be the total cost for processing σ xy over L xy and σ over {x,y}  L, respectively. Since r j can be either x or y, ALG * (σ xy ) = ALG xy * (σ) = ALG (x,j) + ALG (y,j). Then, ALG satisfies pairwise property if ALG * (σ xy ) = ALG xy * (σ). Since the relative order of any two elements x and y  L is the same as their relative order in L xy, ALG(σ xy ) and ALG xy * (σ) are the same for all x and y pairs. For example, if r j = x, ALG * (σ xy ) = ALG xy * (σ) = 0 + 0 and if r j = y, ALG * (σ xy ) = ALG xy * (σ) = 1 + 0, assuming that x is ahead of y. Therefore, Lemma 1.1 holds. if x is in front of r j otherwise (including x = r j )

3 Exercise 1.12 Prove that TIMESTAMP satisfies the pairwise property TIMESTAMP Algorithm ( each element x maintains 2 timestamps, Recent x and Previous y ) When an element x is accessed if Recent x = 0 then Recent x  current time /* first time request */ else Previous x  Recent x, Recent x  current time examine each item y preceding x from the front of the list if Previous y < Previous x then move x before such a first item y. end-if end-if Proof using Lemma 1.1 Consider two elements x and y in the list L. Let σ xy be a subsequence of σ including all occurrences of only x and y. Let L xy be a list containing only x and y in the same initial order as in L. If the timestamp algorithm is run on L xy with σ xy and {x, y}  L with σ, the relative order of x and y in L and L xy depends only on which of Previous x and Previous y is greater. Thus, if and only if x is requested more recently than y, x is moved before y in both lists, L and L xy which means the relative order of the two elements in L xy is the same as their relative order of x and y in the original list L. Therefore, according to Lemma 1.1, the timestamp algorithm satisfies the pairwise property.

4 Exercise 3.7 Show that algorithm FIFO is not a marking algorithm Proof by contradiction: Assume that FIFO is a marking algorithm for k-phase partition of any fixed sequence σ. Then FIFO should not evict any marked page during some k phase. Without a loss of generality, let’s consider a cache with k slots which are indexed by i, 1  i  k, in the order of placement into the cache. Now, suppose the first request of page x during a k-phase is the i th page in the cache. So, this first request is hit and page x is marked after the request is processed. Then, for any remaining k-1 page requests, page x should not be evicted. Let i = 1 and there are i page faults within remaining k-1 page requests. This makes FIFO evict page x before the end of the k-phase. This contradicts our hypothesis. Therefore, FIFO is not a marking algorithm. Marking algorithm Each page in memory is associated with a bit called its mark. A page is marked when it is first requested and a marking algorithm never evicts a marked page from its cache during k pages accesses.


Download ppt "CSE 5314 On-line Computation Homework 1 Wook Choi Feb/26/2004."

Similar presentations


Ads by Google