You are on page 1of 16

High Performance Computing

Lecture 13

Matthew Jacob
Indian Institute of Science
Main Memory Management
 Example: Paged Virtual Memory
 Recall: Need for Address Translation
 To translate a virtual address to the corresponding
physical address, a table of translation information is
needed
 The size of the address translation table ..
 … can be reduced by not managing translations on
byte basis but at some larger granularity
 Page: fixed size unit of memory (contiguous memory
locations) for which a single piece of translation
information is maintained

2
Paged Virtual Memory
PROGRAM/PROCESS
Virtual Address Space
0x00000000
256B
0x000000FF
0x00000100
256B
0x000001FF
0x00000200

0xFFFFFFFF
3
Paged Virtual Memory
PROGRAM/PROCESS
Virtual Address Space
0x00000000
Virtual
Page 0
0x000000FF
0x00000100 0x00000124:

Virtual
0x000001FF Page 1
0x00000200


Virtual
Page
0xFFFFFFFF 0xFFFFFF

4
Paged Virtual Memory
PROGRAM/PROCESS
Virtual Address Space MAIN MEMORY
Physical Address Space
0x00000000 0x000000 0x000024:
Virtual Physical
Page 0 256 B
0x000000FF 0x0000FF Page 0
0x00000100 0x00000124:

Virtual
If Virtual Page 1
0x000001FF Page 1 is currently …
0x00000200
mapped to
Physical Page 0
… 0xFFFFFF
Virtual
Page
0xFFFFFFFF 0xFFFFFF

5
Address Translation
VPN PPN

Virtual address Physical address

Offset Offset

Virtual page number Physical Page


(VPN) Number (PPN)

Translation table
PAGE TABLE
6
Address Translation
PPN

Virtual address VPN Physical address

Offset Offset

Virtual page number Physical Page


(VPN) Number (PPN)

PAGE TABLE
7
Keeping Track: Page Table Entry
PPN

VPN

8
What’s happening…
Main Memory

Processes
P1 P2 Pn

Contents of
virtual pages

9
Recall: About Memory
 What is memory?
 Something that can remember things
 There are different kinds of memory in a
computer system
 Some remember by the state an electrical circuit
is in e.g., SRAM
 Others remember by the amount of electrical
charge stored in a capacitor e.g., DRAM – “Memory”
 Yet others remember by magnetic or optical
properties e.g., Hard disk drive/Mag Tape, VCD/DVD
 They can vary substantially in their speed
and capacity
10
What’s happening… Hard Disk
Page Tables
Main Memory
P1 0 0
1 -
0
2 - P1 P2 Pn
3 - 0 2
1
3

0 - 1
2 P2 1 -
2 3 Contents of
3 3 - virtual pages

0 2
Pn 1 -
2 1
3 -
11
Keeping Track: Page Table Entry
PPN Disk Address

VPN

12
What’s happening… Hard Disk
Page Tables
Main Memory
P1 0 0
1 -
0
2 - P1 P2 Pn
3 - 0 2
1
3

0 - 1
2 P2 1 -
2 3 Contents of
3 3 - virtual pages

Question: What if 0 2
Process P1 now Pn 1 -
accesses a 2 1
variable that is on 3 -
its virtual page 3? 13
Page Fault
 Situation where virtual address generated by
processor is not available in main memory
 Detected on attempt to translate address
 Page Table entry is invalid

14
Keeping Track: Page Table Entry

itb
lid
Va
PPN Disk Addr

VPN

15
Page Fault
 Situation where virtual address generated
by processor is not available in main
memory
 Detected on attempt to translate address
 Page Table entry is invalid
 Must be `handled’ by operating system
1. Identify slot in main memory to be used
2. Get page contents from disk
3. Update page table entry
 Data can then be provided to the processor

16

You might also like