Mathematical Definitions of Page Replacement Algorithms
Theoreticians don't like to express definitions
in informal, intuitive language (such as "LRU replaces the page that
was used least recently.") Pretend(?) that you are a theoretician
and express LRU, FIFO, and LFU mathematically. This means, you must
define the page to be replaced in terms of known mathematical functions
such as min, max, set functions, etc. and/or functions you define yourself
that are mathematical. Don't forget to include tie-breaking rules and to
cover all possiblities. For example:
Let r(1), r(2), r(3), ... r(t), ... r(T) be a memory reference string.
The intuitive definition of "forward distance" f(t,x) at time t is
the distance to the first reference to page x after time t.
The mathematical definition is:
f(t,x) = k if r(t+k) is the first occurrence of x in
r(t+1), r(t+2),...r(T)
= infinite if x is not a member of the set
{r(t+1), r(t+2), ... r(T)}
Then, a mathematical definition of OPT would be:
OPT Page Replacement:
Let S be the set of pages currently in memory.
At time t, OPT chooses page z to replace where z satisfies:
f(t,z) = max [ f(t,u) ]
u in S
If there is more than one page z1 and z2 with f(t, z1) = f(t, z2) = INFINITE,
then choose the page that is larger (Choose z1, if z1 > z2 else choose z2.)