Like aging, except the referenced bit is simply added to the
age instead of shifted into the left. The age is simply a sum of the reference bits over time.
Performs poorly because it treats two references the same
regardless of when they occurred.
Working Set
Programs need a certain set of pages.
Working set algorithm is based on keeping an estimate of that set
in memory.
Working set.
The working set of size k at time t, given as
w(k,t), is the set of pages referred to in the last
k memory references at time t.
The time t should be a count of memory references, but usually
time is used.
For instance:
Given the sequence of page references (ending at t at left,
with older references to the right):
10 15 10 12 10 15 27 10 15 27 19 10 15 19 12 15
Produce the following values:
w(1,t)
= {10}
w(2,t) through w(3,t)
= {10,15}
w(4,t) through w(6,t)
= {10,12,15}
w(7,t) through w(10,t)
= {10,12,15,27}
w(11,t) through w(17,t)
= {10,12,15,19,27}
Increasing function of k:
OS Furniture.
Each process has an age, which is just the amount of time it has run.
When the OS moves the process to the running state, record the
current clock time as the start time.
When the OS moves the process from the running state,
add the difference between the current clock time and
the start time to the process age.
Each page has a last-referenced time.
Periodically check each page. If the referenced bit is one,
the last-referenced time of the page is set to
the age of the process which the page belongs to.
Then clear the ref bit.
Each page has an age, which is simply the current time less
the last-referenced time.
Basic procedure
Don't know the optimal k value, so pick one and call it
τ. Try to keep w(τ,t) pages in memory for each
process.
On a fault, evict a page whose age is greater than τ.
WS-Clock algorithm. On a fault:
Examine the current page. If R=1, clear it
and try the next page.
If the page age ≤ τ, try the next page. (Third chance?)
Else (the page age > τ)
If M=0, evict this page. Done.
If M=1, schedule a write, and try the next page. (Not
a fourth chance, just house arrest.)
The number of writes scheduled may be limited to a reasonable maximum.
If the hand goes all around and finds not candidate,
If some writes were issued, wait for one to finish, and use that.