CS 3733 Operating Systems Notes: Virtual Memory
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.
- Reserve one bit in each page table entry for a valid bit.
- Modify the hardware (MMU) so that when a page table entry is accessed,
the valid bit is checked.
- If the valid bit is set, no change.
- If the valid bit is clear generate an interrupt (called a page fault
interrupt).
- This is the only hardware modification necessary.
The rest is done in software.
- 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.
- When a page fault interrupt occurs:
- Remove the running process from the CPU.
It will be put in the waiting state, waiting for a disk access.
- 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.
- Find a free frame and allocate it to this process.
Set the corresponding page table entry, with its valid bit set to 1.
- Schedule a disk access to read the appropriate data into this newly
allocated frame.
- 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.
- A process may be larger that the physical memory of the machine it is
running on.
- If an address translation is satisfied by the TLB, the page table is not
accessed and a page fault does not occur.
- The fraction of memory accesses that produce a page fault is called the
page fault rate.
Virtual Memory 1
Memory access time calculations
Suppose it take 5 ns. to access memory when no page fault occurs.
Suppose that page fault rate is p, where p is between 0 and 1.
What is the effective memory access time?
We need to know that disk access time.
We will use 10 ms. for a typical disk access time.
Note: 10 ms. = 107ns.
For what value of p with page faults double the effective memory access
time?
Can we get the page fault rate down this low?
Maybe not, but there are other tricks we can pull!
Next Notes
Back to CS 3733 Notes Table of Contents