Docsity

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

Toggle sidebar
bg1
CS 333
Introduction to Operating Systems
Class 12 - Virtual Memory (2)
Jonathan Walpole
Computer Science
Portland State University
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39

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!