Caches and Virtual Memory

Fully Associative Caches

Cache organizations

Problems with Direct Mapped Caches

Fully Associative Cache Characteristics

Set Associative Caches

More cache terminology

Cache Replacement

Writing to Caches

Write-through

Write-back

Cache Performance

AMAT = (hit rate * hit-time) + (miss rate * miss-latency)

Cache hierarchy

Multiple level caches to balance capacity and access latency

Introduction to Virtual Memory

Motivation

Virtual memory addresses two main issues: Capacity and safety

Virtual Memory idea

Address Translation

We will focus on paging as it is used more commonly

Paging

Page address translation

Practice problem

▪What is the size of the page table given a 32-bit virtual address space, 4 KB physical pages, and 1 GB of main memory? Page offset: 12-bits Virtual page number: 32-12 = 20-bits → 1M page table entries Status bits: 6-bits Physical page number: 30-12 = 18-bits Page table entry size: 18+6 = 24-bits Page table size: 24Mbits = 3MB

Multi Level Page Tables

Problem with one level page tables

â–ŞPage table size: 3MB â–ŞEach application requires its own page table

One level page table reserves space for all possible virtual pages

Multi-level page tables characteristics

â–ŞThe last level tables hold the physical page number â–ŞA table at any other level holds pointer to tables at the next level. â–ŞAdvantage: tables are inserted only if the corresponding part of the address space is in use

Storage cost for two level page table

Page table storage varies with virtual address space actually used

Address translation with 2-level page table

TLB

Fast page table access

TLB status bits

Virtual memory: full picture