Lecture 21 Virtual Memory
Lecture 21 Virtual Memory
Physical address
FIG. 5.25 (Bottom) Mapping from a virtual to a physical address: The page size both for physical & virtual memory is
212 = 4 KB since 12 bits for offset. The number of physical pages allowed in memory is 218, since the physical page number
has 18 bits in it. Thus, main memory can have at most 1 GB (230), while the virtual address space is 4 GB (232).
Virtual memory addressing: page tables
Page table:
Page table
-The• page table
Library containing
analogy: the card thecatalog
virtual to physical address translations in a
virtual memoryall
• Indexing system.
pages in virtual memory
-Page• Each
table,program
which ishas stored
its ownin page
memory,tableis typically indexed by the virtual
page• number;
OS creates each entry
disk space in the table
for all the contains
pages of the physical
every processpage number for
that virtual pageofif athe
• The state page isiscurrently
process specifiedinbymemory.
the page table, PC and registers
• Active and
-To indicate inactive processes
the location of the page(saving
table inand loadingthe
memory, page table register,
hardware includes
PC and the other registers)
a register that points to the start of the page table; we call this the page table
register.
Page table entries
-Each program has its own page table.
• Physical page or disk address
-OS•creates disk space for all the pages of every process.
Tag is not necessary (the index specifies the page address)
• Validthe
-Because page
bit: 1 - thetable
page contains a mapping
is in memory; for every
0 - the page possible virtual
is on disk
page, no tags are
• Reference required.
(use) bit: LRU scheme for replacing pages
• Dirty bit ( the page has been written): write-back scheme
• Information for the process using the page (memory protection)
Example
• 32-bit virtual address, 4KB page, 4 byte entry - 4MB for a page table
• 250 processes X 4MB = 1GB !
• Reducing the page table size
Virtual memory addressing: address translation
Virtual pageı
number
Page table
Physical memory
Physical page orı
Valid disk address
Virtual page
1
1
1
1
0
1
1
0
1 Disk storage
1
0
1