資源描述:
《操作系統(tǒng)教程09.ppt》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫(kù)。
1、Chapter9:VirtualMemoryBackgroundDemandPagingCopy-on-WritePageReplacementAllocationofFramesThrashingMemory-MappedFilesAllocatingKernelMemoryBackgroundVirtualmemorySeparationofuserlogicalmemoryfromphysicalmemoryOnlypartoftheprograminmemoryLogicaladdressspace>=physicaladdressspaceInmany
2、cases,theentireprogramnotneeded:ErrorcodeArrays,lists&tablesallocatedmorethanneedCertainoptions&featuresofaprogramrarelyusedBackgroundBenefits:ProgramscanbelargerthanphysicalmemoryProgrammersneedn’tcareaboutmemorylimitationsMoreprogramscouldberunsimultaneouslyLessI/Oneeded,eachuserpr
3、ogramwouldrunfasterEasy2sharefilesamongseveralprocessesMoreefficientprocesscreationDrawbacks:VirtualMemoryThatisLargerThanPhysicalMemory?Virtual-addressSpaceSparseaddressspaces(holes)SharedLibraryUsingVirtualMemoryLibrarycanbesharedCommunicationFork()systemcallVirtualMemoryVirtualme
4、morycanbeimplementedvia:DemandpagingPagingondemandDemandsegmentationSegmentingondemandDemandPagingPagingondemandBringapageintomemoryonlywhenitisneededLessI/OneededLessmemoryneededFasterresponseMoreusersLazyswapperneverswapsapageintomemoryunlesspagewillbeneededSwapperthatdealswithpage
5、sisapagerTransferofaPagedMemorytoContiguousDiskSpaceValid-InvalidBitAvalid–invalidbitforeachpagetableentryAllaresettoiinitiallyv?in-memory&legali?not-in-memory?pagefaultwhenreferencedinvalidreference?abortnot-in-memory?bringtomemoryvvvvii….Frame#valid-invalidbitpagetablePageTableWhe
6、nSomePagesAreNotinMainMemoryPageFaultpagefaultFirstreferencetoapagewilltraptooperatingsystem:Invalidreference?abortValidbutnotinmemoryFindafreeframe(fromthefreeframelist)SwappageintoframeResetpagetablesSetvalidationbit=vRestarttheinstructionthatcausedthepagefaultStepsinHandlingaPage
7、FaultPageFault(Cont.)RestartinstructionC=A+B1.fetchtheinstruction2.fetchA3.fetchB4.AddAandB5.StorethesuminC(Cnotinmemory)ProblemscanbeignoredRepetition1instructioncauseNpagefaultsPageFault(Cont.)Restartinstruction1instructionmodifyNlocationsE.g.MVC(movecharacter),canmove256bytesBlock
8、smaystraddle