Back
to Chapter 4
Virtual Memory: Move parts of programs in
and out of memory.
-
Want to have multiple user's programs.
-
Don't want to have overhead of programmer defined overlays (Split the program
into pieces.)
-
For example, you can have
-
32 M virtual address space on disk
-
4 M physical address space on RAM
-
Need some hardware support.
MMU (Memory Manage Unit):
Physical Memory is broken down into fixed sized blocks (frames) (page
frames).
Logical Memory (Virtual) is broken down into blocks of same size called
pages,
same size of disk segment for easy to read/write from data segment.
The purpose of the page table
is to map virtual pages onto page frames.
The page number is used as an index into page
table, yielding the number of the page frame corresponding to that
virtual page. See figure 4-9.
There is a present/absent bit on page table. From this
bit, we can know which page is on physical memory or on disk.
If a page is absent (not in RAM) then a page
fault occurs. OS must go get page from disk and
put into physical memory.
Page fault: an
attempt to access a page that is not present in physical memory.
Each process has its own view of memory (virtual memory)
Page size is dictated by hardware.
Size of logical address space 2m
Page size 2n
Logical address will be related to m-n
pages and n offset.
For example:
page size: 512
bytes (9 bits) 29 = 512 n = 9
216
= 64 K, m = 16
number of pages
= 216 / 29 = 27 (128 pages) (Each
one point to particular 512 physical memory)
|
Virtual Address
|
-------------->
|
Physical Address
|
|
1 0
|
0 1
|
--------------> |
0 1
|
0 1
|
|
9
|
--------------> |
5
|
Multilevel Page Tables
for quickly access and map logical address to physical address.
Associative Memory - TLBs (Translation Look
aside Buffer)
It is a small hardware device inside the MMU for mapping virture addresses
to physical addresses without going through the page table.
Inverted Page Tables
One entry perpage frame in real memory instead of one entry perpage of
virtual address space.