Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.

27
Virtual Memory

Transcript of Virtual Memory. Hierarchy Cache Memory : Provide invisible speedup to main memory.

Virtual Memory

Hierarchy

• Cache Memory : Provide invisible speedup to main memory

Hierarchy

• Virtual Memory : Provide invisible extension to main memory

Virtual Memory How

• Why?– Allows multiple programs to coexist invisibly• Each program thinks it has all memory

Virtual Memory

• Why?– Allow programs to use more main memory than is

physically present

Terminology

• Virtual Address : address program uses• Physical Address : real address in RAM virtual

address is mapped to

Terminology

• Page : block of memory in virtual address space

• Page Frame : location in physical memory a page is placed

Terminology

• Page Fault : request for a page that is not in physical memory

• Paging : copying desired page from hard drive to RAM

I need this address:

Terminology

• Page Fault : request for a page that is not in physical memory

• Paging : copying desired page from hard drive to RAM

I need this address:Bring in from hard drive

Terminology

• Page Fault : request for a page that is not in physical memory

• Paging : copying desired page from hard drive to RAM

I need this address:Bring in from hard driveRecord where I put it 3

Paging

• Page Table : Records frame frame block mapping– Valid bit : records if page present– Dirty bit : modified, needs to be stored

Addressing

• Virtual address space is 256 bytes– 8 bit address

• 8 pages, 32 bytes in each page23 25

8 bits - VirtualPage Offset3 bits 5 bits

Addressing

• Physical memory is 128 bytes– 7 bit address

• 4 page frames, 32 bytes in each22 25

7 bits - PhysicalPage Frame Offset

2 bits 5 bits

Mapping

• Program asks for virtual address: 00001101

8 bits - VirtualPage Offset000

Page 001101

Byte 13

Mapping

• Program asks for virtual address: 00001101• Page Table says that is page frame 2 : 10

8 bits - VirtualPage Offset000

Page 001101

Byte 13

7 bits - PhysicalPage Frame Offset

10Frame 2

Mapping

• Program asks for virtual address: 00001101• Page Table says that is page frame 2 : 10• Offset in frame same as offset in page: 01101

8 bits - VirtualPage Offset000

Page 001101

Byte 13

7 bits - PhysicalPage Frame Offset

10Frame 2

01101Byte 13

Mapping

• Program asks for virtual address: 00001101• Gets value at: 1001101

8 bits - VirtualPage Offset000

Page 001101

Byte 13

7 bits - PhysicalPage Frame Offset

10Frame 2

01101Byte 13

Another

• 16 bytes of virtual space, 8 of RAM

• Page size : 2 bytes

Another

• 16 bytes of virtual space, 8 of RAM4 bit address 3 bit address

• Page size : 2 bytes1 bit offset

What does 0111 map to?

Larger Scale

Virtual addressed up to 8KPhysical up to 4KPage size 1k

Larger Scale

Virtual addressed up to 8KPhysical up to 4KPage size 1k

Page Sizes

• Small page size = larger page table

Page Sizes

• Small page size = larger page table• Large page size = more unused data

in pages

Paging & Caching

• Page table heldin main memoryby OS

Paging & Caching

• Page table heldin main memoryby OS

• Every mappinggoes to main memory…Cache is worthless!

TLB

• Transition look-aside bufferCache for page table– Subset of page table– Fully associative– May be multiple levels

TLB

• Using TLB