Chapter 8
Virtual Memory


Implementing LRU

Perfect LRU:

Problem: O/S must record time stamp for each memory access. To find the page that should be thrown out, O/S has to look at all pages.

Another way:

Problem: Still too expensive. The O/S must make 6 pointer references on each memory access.


Approximating LRU

Hardware: Single reference bit. On each access to a page, the hardware sets the reference bit to 1.

Second Chance (Clock) Algorithm:


Paging Algorithms - Clock Algorithm

Will the clock algorithm always find a page to replace?

What if all reference bits are 0?

What is happening when the hand is moving quickly?

What is happening when the hand is moving slowly?

One way to view the clock algorithm is as a crude partitioning into two categories: young pages and old pages. Why not partition the pages into more than two categories?


Paging Algorithms - Nth Chance Algorithm

Idea: Do not throw a page out until the clock hand has swept by it n times.


Paging Algorithms - Enhanced Second Chance

It is cheaper to replace a page that has not been written to (a "clean" page) since it need not be written back to disk. Idea: Have the O/S skip over modified pages an extra time.

The Algorithm:


Multiprogramming Replacement Policies

Thrashing: Memory is over-committed and pages are tossed out while they are still in use. Instead of maintaining the illusion of RAM speed, memory references slow down to near disk access time.

What can we do in a multiprogramming environment to limit thrashing?


Per-process replacement -- working sets

Implementing working sets

What happens if T is too small?

What happens if T is too large?