Docsity

CS241 System Programming - Lecture 30: Memory Management and TLB, Study notes of Computer Science

Partial preview of the text

Download CS241 System Programming - Lecture 30: Memory Management and TLB and more Study notes Computer Science in PDF only on Docsity!

CS241 System Programming

Memory Management (III)

Klara Nahrstedt Lecture 30 4/7/

4/7/

CS 241 - System Programming,

Klara Nahrstedt

Content

z^

Paging Implementation

z^

TLB – Translation Look-aside Buffer

z^

Inverted Page Tables

Translation Lookaside Buffer

(TLB)

offset

Virtual address

... PPage#

PPage#

PPage#

PPage #

offset

VPage #

TLB Hit

Miss

Realpagetable

VPage# VPage# VPage#

Physical address

TLB Function

z^ If a virtual address is presented to MMU, thehardware checks TLB by comparing all entriessimultaneously (in parallel). z^ If match is valid, the page is taken from TLBwithout going through page table. z^ If match is not valid

-^ MMU detects miss and does an ordinary pagetable lookup. –^ It then evicts one page out of TLB and replaces itwith the new entry, so that next time that page isfound in TLB.

Page Mapping Example

Page Table^0101101

Virtual Memory Address (P,D) Physical Address (F,D)

Associative Lookup

First

Table organized byLRU

Page Mapping Example: next reference

Page Table^0101101

Virtual Memory Address (P,D) Physical Address (F,D)

Associative Lookup

First

Table organized byLRU

Paging Implementation Issues

z^ TLB can be implemented using

-^ Associative registers –^ Look-aside memory –^ Content-addressable memory

z^ TLB hit ratio (Page address cache hit ratio)

-^ Percentage of time page translation found inassociative memory

Software-Controlled TLB

z^

On a miss in TLB, VM software^ –^

Write back if there is no free entry

-^

Check if the page containing the PTE is in memory

-^

If no, perform page fault handling

-^

Load the PTE into the TLB

-^

Restart the faulting instruction z^

On a hit in TLB, the hardware checks valid bit^ –^

If valid, pointer to page frame in memory

-^

If invalid, the hardware generates a page fault^ z^

Perform page fault handling z Restart the faulting instruction

z^

Example: SPARC, MIPS, Alpha, HP-PA, IA-64,PowerPC

Effective Access Time

z^ TLB lookup time =

ε^

time unit

z^ Memory cycle =

m

μs

z^ TLB Hit ratio =

z^ Effective access time (Eat)

-^ Eat

m^

+^ ε

)α +

m^

+^ ε

α)

-^ Eat

m^

+^ ε

–^
m^ α

4/7/

CS 241 - System Programming,

Klara Nahrstedt

Summary

z^

TLB allows for rapid mapping of virtualaddresses to physical addresses withoutgoing through the page table

z^

TLB management possible in software