Virtual Memory II

Tom Kelliher, CS 318

Apr. 27, 1998


From last time:



Replacement Policies

LRU Implementation

  1. Maintain frame list as a ``stack.'' Implementation?

  2. Timestamp page table entry on each access. Implementation?

  3. Simulating the time stamp through recording and concatenation of reference bits.
    1. Implementation: system daemon and timer interrupt.

    2. How often to record?

    3. How many bits?

Second Chance FIFO

AKA clock algorithm.

  1. Maintain process' frame list in a circular queue.

  2. The ``victim'' pointer.

  3. Victim page referenced: skip over, resetting reference bit.

  4. All pages referenced: pure FIFO.

  5. Enhancement: examine (reference bit, dirty bit):
    1. Four combinations --- priorities?

    2. Possibly several passes through the queue.

Placement Policies

How are frames allocated to processes?


  1. Minimum # of frames.

  2. Static vs. dynamic policies.

  3. Global vs. local.

  4. Thrashing.

  5. Optimizations.

  6. Interaction with I/O subsystem.

Minimum Number of Frames

Must have sufficient frames in memory to execute an instruction.


  1. Instruction fetch: One or two frames.

  2. Operand fetch/store: One or two frames per operand.

  3. Massive indirection?

Simple Allocation Policies

  1. Equal allocation.
    1. How realistic?

  2. Proportional allocation.
    1. Allocated space according to need.
      1. Process i needs pages.

      2. Total need is pages.

      3. Memory broken into m frames.

      4. Process i granted frames.

    2. How realistic?

    3. Can be generalized to priority schemes.

Problems with static policies.

Suppose we re-adjusted proportional at intervals. Any improvement?

Global and Local Replacement

If a victim page must be selected, what is the candidate pool?

  1. Local: page frames of only the faulting process.

    Process' fault rate not dependent on other process' behavior.

  2. Global: any page frame.
    1. Frame stealing.

    2. Interdependence of processes.

  3. Combined policy (prioritized).


  1. Effect of CPU utilization on degree of multiprogramming.

  2. Effect of degree of multiprogramming on frame distribution.

  3. Effect of frame distribution on page fault rate.

  4. Effect of page fault rate on CPU utilization.

CPU utilization low due to paging, so more processes started, making memory situation worse, leading to more paging, lowering CPU utilization, so more processes started, ...

Adaptive Allocation Policies

Attempt to adapt to process behavior.

Action on memory over-commitment?

Working Set Model


  1. ``Locality.''

  2. Number of pages for each locality.

  3. This is the working set.

How do we determine the working set?

  1. : working set window.

  2. : working set interval.

  3. Every time units, examine last references and determine number of unique references. That number is the working set size.

  4. How do we implement this?
    1. System daemon and timer interrupt.

    2. Concatenate a few reference bits.

  5. What happens if the window straddles two localities, etc.? (Working set aliasing)

Page Fault Frequency

  1. Ultimate goal: maintain each process' page fault rate within some target region.

  2. Implementation: Track each process' fault rate
    1. If above target region: allocate more frames to process.

    2. If below target regions: de-allocate frames.

  3. Implementation?


  1. Pre-paging.

  2. Page Size:
    1. Reasons for large page size:
      1. Smaller page table.

      2. Maximize I/O efficiency.

    2. Reasons for small page size:
      1. Better match localities.

      2. Decrease internal fragmentation.

    3. Page sizes have increased over time to accommodate faster CPUs, memory, making page faults more costly.

  3. Program Structure:
    1. Burroughs Algol: Each row of a 2-D array is allocated in a separate segment.

    2. A 1-D array is allocated in a single segment.

    3. For most speed, simulate a 2-D array with a 1-D array.

VM and the I/O Subsystem

What happens if I/O is occurring to a page and it gets paged out?


  1. Lock buffer pages in memory.

  2. All I/O occurs to kernel space with memory copies to/from user space.

  3. Copies expensive; is there another way?

Thomas P. Kelliher
Sat Apr 25 10:28:42 EDT 1998
Tom Kelliher