Download presentation
Presentation is loading. Please wait.
1
Memory Management & Virtual Memory
2
Hierarchy Cache Memory : Provide invisible speedup to main memory
3
Hierarchy Virtual Memory : Provide invisible extension to main memory
4
Terminology Virtual/Logical Address : Physical Address : Page :
Address program uses Size determined by bits in memory address Physical Address : Determined by available memory Page : Block of memory 4KB+ in Windows/Linux
5
Memory Management Memory Management
Turns Virtual addresses used by processor into Physical addresses in memory
6
Virtual Memory How Why? Logical space can be independent of physical space Programs don't have to care how many GB ram you have
7
Virtual Memory Why? Allow programs to use more main memory than is physically present Hard drive used as extra space
8
Virtual Memory How Why? Allows multiple programs to coexist
9
Virtual Memory How Why? Allows multiple programs to coexist
Everyone can use same logical addresses
10
Virtual Memory How Why? Allows multiple programs to coexist invisibly
Some memory can be shared by processes
11
Virtual Memory How Why? Allows multiple programs to coexist invisibly
Memory Management Unit can prevent access to unowned memory
12
Terminology Page Table : stores physical address of every page
Paging : copying page from hard drive to RAM Page Fault : accessing a virtual page not in RAM
13
Example Assume each page is 4KB (4096 bytes)
32KB Virtual space, 12KB Physical
14
Example Assume each page is 4KB (4096 bytes) CPU asks for address 100
100 bytes into page 0
15
Example Assume each page is 4KB (4096 bytes) CPU asks for address 100
100 bytes into page 0 Virtual page 0 is in Physical Page 2
16
Example Assume each page is 4KB (4096 bytes) CPU asks for address 100
100 bytes into page 0 Virtual page 0 is in Physical Page 2 Physical address is 4K *
17
Example 2 Assume each page is 4KB (4096 bytes)
CPU asks for address 4296 200 bytes into page 1
18
Example 2 Assume each page is 4KB (4096 bytes)
CPU asks for address 4296 200 bytes into page 1 Not in physical memory Page Fault
19
Example 2 Assume each page is 4KB (4096 bytes)
CPU asks for address 4296 200 bytes into page 1 Kick a page out to drive
20
Example 2 Assume each page is 4KB (4096 bytes)
CPU asks for address 4296 200 bytes into page 1 Load desired virtual page into physical memory Update Page Table 3
21
Example 2 Assume each page is 4KB (4096 bytes)
CPU asks for address 4296 200 bytes into page 1 Virtual page 1 is now in Physical Page 3 Physical address is 4K * 3
22
Page Faults Page Fault = 40,000,000 cycles with HDD! 600,000 with SSD
23
Page Sizes Small page size More book keeping More physical pages
Less thrashing
24
Page Sizes Large page size Less book keeping More temporal locality
If we use it all Fewer physical pages More thrashing
25
Page Mapping Memory addresses broken into
Page Offset : Enough bits to specify every address in page Page # : All the rest
26
Page Mapping Computer has 32 bit address space, 1GB of physical memory and 4KB pages 1GB = 230 Physical address need 30 bits
27
Page Mapping Computer has 32 bit address space, 1GB of physical memory and 4KB pages Pages are 212 bytes 12 bits for offset
28
Page Mapping Computer has 32 bit address space, 1GB of physical memory and 4KB pages Pages are 212 bytes 12 bits for offset Virtual page number = 32 – 12 = 20 bits
29
Page Mapping Computer has 32 bit address space, 1GB of physical memory and 4KB pages Pages are 212 bytes 12 bits for offset Virtual page number = 32 – 12 = 20 bits Physical page number = 30 – 12 = 18 bits
30
Process Need logical address
31
Process Find virtual page # and offset in page
32
Process Find virtual page # and offset in page Look up in page table…
33
Process Find virtual page # and offset in page Look up in page table… Get physical page #
34
Process Find virtual page # and offset in page Look up in page table… Get physical page # Combine with offset to make physical address
35
Paging & Caching Page table held in main memory by OS
36
Paging & Caching Page table held in main memory by OS
Every mapping goes to main memory… Cache is worthless!
37
TLB Translation look-aside buffer Cache for page table
Subset of page table Fully associative May be multiple levels
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.