Docsity

Virtual Memory Addresses in Operating System | CS 333, Study notes of Operating Systems

Partial preview of the text

Download Virtual Memory Addresses in Operating System | CS 333 and more Study notes Operating Systems in PDF only on Docsity!

CS 333

Introduction to Operating Systems^ Class 11 – Virtual Memory (1)

Jonathan Walpole Computer Science Portland State University

Virtual addresses^ ‰^ Virtual memory addresses (what the process uses)^ ™^ Page number plus byte offset in page^ ™^ Low order n bits are the byte offset^ ™^ Remaining high order bits are the page number

bit 0 bit n- bit 31^ 20 bits

12 bits^ offset

page number Example: 32 bit virtual address Page size = 2

12 = 4KB

Address space size = 2

32 bytes = 4GB

Address translation^ ‰^ Complete set of address mappings for a process arestored in a page table in memory^ ™^ But accessing the table for every address translation istoo expensive^ ™^ So hardware support is used to map page numbers toframe numbers at full CPU speed

  • Memory management unit (MMU) has multiple registers formultiple pages and knows how to access page tables • Also called a translation look aside buffer (TLB) • Essentially a cache of page table entries

The BLITZ architecture^ ‰^ The page table mapping:^ ™^ Page --> Frame^ ‰^ Virtual Address (24 bit in Blitz):^ ‰^ Physical Address

(32 bit in Blitz):

bits

19 bits

The BLITZ page table^ ‰^ Two page table related registers in the CPU^ ™^ Page Table Base Register^ ™^ Page Table Length Register^ ‰^ These define the page table for the “current” process^ ™^ Must be saved and restored on process contextswitch^ ‰^ Bits in the CPU “status register”^ “System Mode”^ “Interrupts Enabled”^ “Paging Enabled”

1 = Perform page table translation for every memory access 0 = Do not do translation

The BLITZ page table^ ‰^ A page table entry

frame^ number

D^ R^ W^ V

unused dirty bit referenced bitwritable bit

valid bit

19 bits

The BLITZ page table^ ‰

23 page

number

offset

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

page table base register^012 2K

virtual address

The BLITZ page table^ ‰

23 page

number

offset

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

page table base register^012 2K

virtual address physical address

The BLITZ page table^ ‰

23 page

number

offset

offset

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

page table base register^012 2K

virtual address physical address

The BLITZ page table^ ‰

23 page

number

offset

offset

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

frame^ number

D^ R^ W^ V

unused

page table base register^012 2K

virtual address frame^ number physical address

Page tables^ ‰^ When and why do we access a page table?^ ™^ On every instruction to translate virtual to physicaladdresses? NO!^ ™^ In real machines it is only accessed

• On TLB miss faults to refill the TLB • During process creation and destruction • When a process allocates or frees memory?

Translation Lookaside Buffer (TLB)^ ‰^ Problem:^ ™^ MMU can’t go to page table on every memory access!

Translation lookaside buffer

CPU^

p^ o

f^ o pageframe## TLB

TLB Hit^

Physicalmemory PageTable

Hardware operation of TLB^ Page

Number

Frame^ Number

D^ R^ W^ V

unused

50

D^ R^ W^ V

unused

24

D^ R^ W^ V

unused

19

D^ R^ W^ V

unused

6

D^ R^ W^ V

unused

Key

Other

‰