previous
 next 
CS 3733 Operating Systems Notes: Virtual Memory
(change semester)

Virtual Memory:
We will discuss only one type of virtual memory: demand paged virtual memory.

The idea: Keep some (or most) of the address space of a process on disk, rather than in memory.
  1. Reserve one bit in each page table entry for a valid bit.
  2. Modify the hardware (MMU) so that when a page table entry is accessed, the valid bit is checked.
    1. If the valid bit is set, no change.
    2. If the valid bit is clear generate an interrupt (called a page fault interrupt).
  3. This is the only hardware modification necessary. The rest is done in software.
  4. When a process is brought into memory, only allocate memory for the first page.
    Other page table entries are initialized with the valid bit clear.
  5. When a page fault interrupt occurs:
    1. Remove the running process from the CPU.
      It will be put in the waiting state, waiting for a disk access.
    2. Modify the stored program counter so that it points to the instruction that caused the page fault.
      Undo any parts of that instruction that have already been executed.
    3. Find a free frame and allocate it to this process.
      Set the corresponding page table entry, with its valid bit set to 1.
    4. Schedule a disk access to read the appropriate data into this newly allocated frame.
    5. When the I/O operation completes, the process is moved to the ready queue (as usual) and it will start with the instruction that caused the page fault.
  6. A process may be larger that the physical memory of the machine it is running on.
  7. If an address translation is satisfied by the TLB, the page table is not accessed and a page fault does not occur.
  8. The fraction of memory accesses that produce a page fault is called the page fault rate.
Virtual Memory 1


Memory access time calculations

Next Notes

Back to CS 3733 Notes Table of Contents