Virtual Memory Overview - University of California, …cs61c/fa16/disc/13/...Find the original bits...
Transcript of Virtual Memory Overview - University of California, …cs61c/fa16/disc/13/...Find the original bits...
VirtualMemoryOverview
Virtualaddress(VA):Whatyourprogramuses
VirtualPageNumber PageOffset
Physicaladdress(PA):Whatactuallydetermineswhereinmemorytogo
PhysicalPageNumber PageOffset
With4KiBpagesandbyteaddresses,2^(pageoffsetbits)=4096,sopageoffsetbits=12.
TheBigPicture:LogicalFlowTranslateVAtoPAusingtheTLBandPageTable.ThenusePAtoaccessmemoryastheprogramintended.
PagesAchunkofmemoryordiskwithasetsize.Addressesinthesamevirtualpagegetmappedtoaddressesinthesamephysicalpage.Thepagetabledeterminesthemapping.
ThePageTable
Index=VirtualPageNumber(VPN)(notstored)
PageValid
PageDirty
PermissionBits(read,write,...)
PhysicalPageNumber(PPN)
0
1
2
…
(Maxvirtualpagenumber)
Eachstoredrowofthepagetableiscalledapagetableentry(thegrayedsectionisthefirstpagetableentry).Thepagetableisstoredinmemory;theOSsetsaregistertellingthehardwaretheaddressofthefirstentryofthepagetable.Theprocessorupdatesthe“pagedirty”inthepagetable:“pagedirty”bitsareusedbytheOStoknowwhetherupdatingapageondiskisnecessary.Eachprocessgetsitsownpagetable.
• ProtectionFault--Thepagetableentryforavirtualpagehaspermissionbitsthatprohibittherequestedoperation
• PageFault--Thepagetableentryforavirtualpagehasitsvalidbitsettofalse.Theentryisnotinmemory.
TheTranslationLookasideBuffer(TLB)
Acacheforthepagetable.Eachblockisasinglepagetableentry.IfanentryisnotintheTLB,it’saTLBmiss.Assumingfullyassociative:
TLBEntryValid
Tag=VirtualPageNumber PageTableEntry
PageDirty PermissionBits PhysicalPageNumber
… … … … …
TheBigPictureRevisited
Exercises
1)Whatarethreespecificbenefitsofusingvirtualmemory?2)WhatshouldhappentotheTLBwhenanewvalueisloadedintothepagetableaddressregister?
3)Aprocessorhas16-bitaddresses,256bytepages,andan8-entryfullyassociativeTLBwithLRUreplacement(theLRUfieldis3bitsandencodestheorderinwhichpageswereaccessed,0beingthemostrecent).Atsometimeinstant,theTLBforthecurrentprocessistheinitialstategiveninthetablebelow.AssumethatallcurrentpagetableentriesareintheinitialTLB.Assumealsothatallpagescanbereadfromandwrittento.FillinthefinalstateoftheTLBaccordingtotheaccesspatternbelow.
Free physical pages:0x17,0x18,0x19
CS61CSpring2015 Discussion12–VirtualMemory
Accesspattern:Read 0x11f0Write 0x1301Write 0x20aeWrite 0x2332Read 0x20ffWrite 0x3415InitialTLB
VPN PPN Valid Dirty LRU0x01 0x11 1 1 00x00 0x00 0 0 70x10 0x13 1 1 10x20 0x12 1 0 50x00 0x00 0 0 70x11 0x14 1 0 40xac 0x15 1 1 20xff 0x16 1 0 3
FinalTLB
VPN PPN Valid Dirty LRU
HammingECC
RecallthebasicstructureofaHammingcode.Givenbits1,...,m,thebitatposition2nisparityforallthebitswitha1inpositionn.Forexample,thefirstbitischosensuchthatthesumofallodd-numberedbitsiseven.
1. How many bits do we need to add to 00112 to allow single error correction?
2. Which locations in 00112 would parity bits be included?
3. Which bits does each parity bit cover in 00112?
4. Write the completed coded representation for 00112 to enable single error correction.
5. How can we enable an additional double error detection on top of this?
6. Find the original bits given the following SEC Hamming Code: 01101112
7. Find the original bits given the following SEC Hamming Code: 10010002
8. Find the original bits given the following SEC Hamming Code: 0100110100001102