Docsity

Virtual Memory and Translation Lookaside Buffer (TLB) in Operating Systems - Prof. Jonatha, Study notes of Operating Systems

Partial preview of the text

Download Virtual Memory and Translation Lookaside Buffer (TLB) in Operating Systems - Prof. Jonatha and more Study notes Operating Systems in PDF only on Docsity!

CS 333

Introduction to Operating Systems^ Class 12 - Virtual Memory (2)

Jonathan Walpole Computer Science Portland State University

Translation Lookaside Buffer (TLB)^ ‰^ Problem:^ ™^ Unless we have hardware support for addresstranslation, CPU would have to go to memory toaccess the page table on every memory access!^ ‰^ In Blitz, this is what happens

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

‰

Hardware operation of TLB^ ‰

23 page

number

offset

frame^ number

offset

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

virtual address

37^ physical address

Key

Other

Hardware operation of TLB^ ‰

23 page

number

offset

frame^ number

offset

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

physical address

Key

Other

virtual address

Hardware operation of TLB^ ‰

23 page

number

offset

frame^ number

offset

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

physical address

Key

Other

virtual address

Software operation of TLB^ ‰^ What if the entry is not in the TLB?^ ™^ Go to page table (how?)^ ™^ Find the right entry^ ™^ Move it into the TLB^ ™^ Which entry to replace?

Software operation of TLB^ ‰^ Hardware TLB refill^ ™^ Page tables in specific location and format^ ™^ TLB hardware handles its own misses^ ‰^ Software refill^ ™^ Hardware generates trap (TLB miss fault)^ ™^ Lets the OS deal with the problem^ ™^ Page tables become entirely a OS data structure!

Page tables^ ‰^ Do we access a page table when a processallocates or frees memory?

Page tables^ ‰^ Do we access a page table when a processallocates or frees memory?^ ™^ Not necessarily^ ™^ Library routines (malloc) can service small requestsfrom a pool of free memory already allocated withina process address space^ ™^ When these routines run out of space a new pagemust be allocated and its entry inserted into thepage table

•^ This allocation is requested using a system call •^ Malloc is not a system call

Page tables^ ‰^ In a well provisioned system, TLB miss faultswill be the most frequently occurring event^ ‰^ TLB miss fault^ ™^ Given a virtual page number we must find the rightpage table entry

•^ Fastest approach – index the page table usingvirtual page numbers •^ …hmm, isn’t that the opposite of what we said lastside? ™ Problem … how to structure our page tables forefficient access and low space overhead

Page table design issues^ ‰^ Page table size depends on^ ™^ Page size^ ™^ Virtual address length^ ‰^ Memory used for page tables is overhead!^ ™^ How can we save space?^ ™^ … and still find entries quickly?^ ‰^ Three options^ ™^ Single-level page tables^ ™^ Multi-level page tables^ ™^ Inverted page tables

Single-level page tables

Single-levelpage table

framesin memory

- •• page number

offset

21-bits

11-bits

Single-level page tables

Single-levelpage table

framesin memory

- •• page number

offset

21-bits

11-bits

Problem: requires one page table entry per virtual page!