Download presentation
Presentation is loading. Please wait.
Published byMohammad Marson Modified over 3 years ago
1
Datorteknik VirtualMemory bild 1 Virtual Memory User memory model so far: Separate Instruction and Data memory In reality they share the same memory space User space 0x00000000 … 0x7fffffff Instruction memory Data memory
2
Datorteknik VirtualMemory bild 2 Virtual to Physical Address Mapping 0x00000000 … 0x7fffffff Physical memory Virtual address Physical address User space Instruction and Data 2 GB Virtual memory 2 GB, HUGE amountPhysical memory only 16 MB
3
Datorteknik VirtualMemory bild 3 Address Mapping 32-bit Virtual Address CP0 MIPS PIPELINE 32 InstrData Physical memory 16 Mb 24-bit Physical Address Arbiter
4
Datorteknik VirtualMemory bild 4 Virtual Address User 1 2 GB Page 0 Page 1 …. 901031 Selects Page # xOffset within page #x Virtual Address 32-bit Page x 1024 Bytes Page n 2 Pages 22 2 Addresses 10
5
Datorteknik VirtualMemory bild 5 Virtual Memory …. Page x Page n Physical memory 16 MB Page x Page 1 Page 0 Not Allocated Yet Secondary Storage Primary Memory Hard Disk 2 GB Page 0 Virtual Address 2 GB
6
Datorteknik VirtualMemory bild 6 Memory Resident Pages Only very few pages are RESIDENT in physical 901031 Selects Page # xVirtual 32-bit AddressOffset 901023 Address Translation of page #x Physical 24-bit Address
7
Datorteknik VirtualMemory bild 7 Page Fault What about a NON RESIDENT page? We know the Virtual Address, but: No Physical Address, since the page is on Hard Disk (SWAPPED) What about a not allocated page We know the Virtual Address, but: We try to access a Virtual Address that we have not (yet) access to, that is an ERROR In both cases we get a PAGE FAULT
8
Datorteknik VirtualMemory bild 8 Page Table …. Page x Hard Disk Physical Memory Page y Virtual Address 2 GB Page y Page Resident Y Physical Addr [23:10] N Place on Hard Disk For Non Resident Pages we get a PAGE FAULT
9
Datorteknik VirtualMemory bild 9 Swapping 2 Gb …. Secondary Storage Physical Memory Page y Virtual Address Page y Resident Y Page y The OS copies Page y to physical memory and restarts the failing user instruction Physical Addr [23:10] Place on Hard Disk
10
Datorteknik VirtualMemory bild 10 Page Fault and the OS A Page Fault is handled by the Kernel (OS) 1) If physical memory not full –Copy the page from hard disk to a empty page X in physical memory –Update the Page Table, Resident = YES, Physical Addr [23:10]=X –Restart the failing instruction in the user program 2) If physical memory full –Choose one page X from physical memory, store it on hard disk at XX –Update the Page Table (X), Resident = NO, place on HD = XX –Proceed with 1) What if page X is unchanged (only read operations), skip storing to hard disk, just set Resident = NO
11
Datorteknik VirtualMemory bild 11 Multiple User Processes User 1 0x00000000 … 0x7fffffff 0x00000000 … 0x7fffffff 0x00000000 … 0x7fffffff Virtual address Physical address User 2 User n …. Virtual memory n * 2 Gb User n User 1 User nUser 1 User 2 Page Table 1 Page Table 2 Page Table n HD address 16 Mbyte
12
Datorteknik VirtualMemory bild 12 Where do we store the Page Tables? 16 Mbyte Page Table 1 Page Table 2 Page Table n User Memory Kernel Memory We store the Page Tables in Kernel memory Protected from User access! DirtyResident Physical Addr [23:10] Place on Hard Disk 2 entries huge array! Store only allocated pages 22 DR
13
Datorteknik VirtualMemory bild 13 Address Mapping 32-bit Virtual Address CP0 MIPS PIPELINE 32 InstrData 24-bit Physical Address Page Table 1 Page Table 2 Page Table n User Memory Kernel Memory User process 2 running Here we need page table 2 for address mapping
14
Datorteknik VirtualMemory bild 14 Translation Lookaside Buffer (TLB) CP0 MIPS PIPELINE 24 32 Virtual Address DRPhysical Addr [23:10] Page Table 1 Page Table 2 Page Table n User Memory Kernel Memory On TLB hit, the 32-bit virtual address is translated into a 24-bit physical address by hardware We never call the Kernel! 32
15
Datorteknik VirtualMemory bild 15 Memory Hierarchy 24 D Valid bit Physical Addr [23:10] User Memory Kernel Memory 16 Mb = 2 pages 14 Hardware is FAST but EXPENSIVE No need to use more than 2 entries STILL TO BIG! Make is smaller. Select a subset of the Page Table and store it in the TLB 14 Page Table 2 V22-bit Page #
16
Datorteknik VirtualMemory bild 16 Address Translation A TLB hit, we get a physical address –The Page # found in TLB and Valid entry (V-bit) –If a Write operation, set Dirty (D-bit) A TLB miss, causes a TLB miss exception –If Page NOT Resident in Physical memory, Page Fault and the OS slide if page X is swapped to hard disk and X in TLB, clear V bit –If Page Resident in Physical memory Find a free TLB entry and update it 1) 22-bit Page #, set V-bit, clear D-bit, 14-bit physical address –If TLB full, chose a TLB entry if D-bit, update Page Table Dirty bit, proceed with 1)
17
Datorteknik VirtualMemory bild 17 TLB control CP0 MIPS PIPELINE 32 Virtual Addr Data bus Control Signals TLB MISS R/W Page Table
Similar presentations
© 2018 SlidePlayer.com Inc.
All rights reserved.
Ppt on indian textile industries in india Ppt on review of related literature thesis Ppt on cell the fundamental unit of life Download ppt on pulse code modulation pcm Ppt on rime of the ancient mariner part 1 and 2 Ppt on job evaluation sample Ppt on ministry of corporate affairs in india Ppt on sources of energy for class 8th pattern Ppt on water scarcity in california Ppt on positive thinking download