CSE 5314 On-line Computation Homework 1 Wook Choi Feb/26/2004
description
Transcript of CSE 5314 On-line Computation Homework 1 Wook Choi Feb/26/2004
CSE 5314 On-line Computation
Homework 1
Wook ChoiFeb/26/2004
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 or
der of every two elements x and y in L is the same as their relative order in Lxy when ALG servers σxy
Proof using the partial cost model which does consider only the cost from negative comparisons u
ntil a requested item is found in the list:
Consider any request sequence σ = r1 , r2, , … ,rn for the list L. σxy is defined to be σ after deletion of all the reque
sts for items except for x and y where x, y L (x ≠ y); Lxy 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 A
LG (x,j) in accessing jth request, rj where:
Let ALG* (σxy) and ALGxy*(σ) be the total cost for processing σxy over Lxy and σ over {x,y} L , respectively. Sin
ce rj can be either x or y, ALG* (σxy) = ALGxy*(σ) = ALG (x,j) + ALG (y,j). Then, ALG satisfies pairwise property
if ALG*(σxy) = ALGxy*(σ).
Since the relative order of any two elements x and y L is the same as their relative order in Lxy, ALG(σxy ) a
nd ALGxy*(σ) are the same for all x and y pairs. For example, if rj = x, ALG*(σxy) = ALGxy
*(σ) = 0 + 0 and if rj =
y, ALG*(σxy) = ALGxy*(σ) = 1 + 0, assuming that x is ahead of y. Therefore, Lemma 1.1 holds.
0
1),( jxALG
if x is in front of rj otherwise (including x = rj)
Exercise 1.12 Prove that TIMESTAMP satisfies the pairwise property
TIMESTAMP Algorithm (each element x maintains 2 timestamps, Recentx and Previousy)
When an element x is accessed
if Recentx = 0 then Recentx current time /* first time request */
else Previousx Recentx , Recentx current time
examine each item y preceding x from the front of the list
if Previousy < Previousx
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 a
nd y. Let Lxy be a list containing only x and y in the same initial order as in L. If the timestamp algorithm is ru
n on Lxy with σxy and {x, y} L with σ, the relative order of x and y in L and Lxy depends only on which of Prev
iousx and Previousy is greater. Thus, if and only if x is requested more recently than y, x is moved before y in b
oth lists, L and Lxy which means the relative order of the two elements in Lxy 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 pair
wise property.
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 s
hould not evict any marked page during some k phase. Without a loss of generality, let’s consider a c
ache with k slots which are indexed by i, 1 i k, in the order of placement into the cache. Now, su
ppose the first request of page x during a k-phase is the ith page in the cache. So, this first request is hi
t and page x is marked after the request is processed. Then, for any remaining k-1 page requests, pag
e x should not be evicted. Let i = 1 and there are i page faults within remaining k-1 page requests. Thi
s 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.