操作系统教学课件OS_08

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

Chapter8MainMemoryOperatingSystem.SchoolofSoftware.HUST2Chapter8:MemoryManagementBackgroundSwapping(交换)ContiguousMemoryAllocation(连续分配)Paging(分页)StructureofthePageTableSegmentation(分段)Example:TheIntelPentiumOperatingSystem.SchoolofSoftware.HUST3ObjectivesToprovideadetaileddescriptionofvariouswaysoforganizingmemoryhardware.Todiscussvariousmemory-managementtechniques,includingpagingandsegmentation.ToprovideadetaileddescriptionoftheIntelPentium,whichsupportsbothpuresegmentationandsegmentationwithpaging(段页式).OperatingSystem.SchoolofSoftware.HUST4Chapter8:MainMemory内存是计算机系统的最重要的资源之一。为提高响应速度及CPU的利用率,必须将多个进程同时放入内存,多进程共享内存。本章介绍内存管理方法。内存管理方法很多,但内容主要涉及下述三个方面:内存分配回收方法地址映射和重定位内存保护OperatingSystem.SchoolofSoftware.HUST5BackgroundProgrammustbebrought(fromdisk)intomemoryandplacedwithinaprocessforittoberun.MainmemoryandregistersareonlystorageCPUcanaccessdirectly.RegisteraccessinoneCPUclock(orless).Mainmemorycantakemanycycles.CachesitsbetweenmainmemoryandCPUregisters.Wedon’tliketodelaytheCPU,sowenormallyaddafasterlayerofmemoryaccessbetweentheprocessorandmainmemorycalledcachememory.Protectionofmemoryrequiredtoensurecorrectoperation..OperatingSystem.SchoolofSoftware.HUST6BaseandLimitRegisters(P276)Apairofbaseandlimitregistersdefinethelogicaladdressspace.OperatingSystem.SchoolofSoftware.HUST7HWaddressprotectionwithbaseandlimitregisters(P277)BaseandLimitregistersareloadedonlybytheoperatingsystemwhichusesspecialprivilegedinstructionsonlyavailableinkernelmode.Sinceonlytheoperatingsystemcanaccessbaseandlimitregisters,thisgivestheoperatingsystemcontrolofusers’memoryanduserprograms.OperatingSystem.SchoolofSoftware.HUST8AddressBinding(P278)Programsnormallyresideondiskinexecutableform,assomekindof.exefile(.exe..dll,.class.Others…)Programmustbebroughtintomemoryforittoberun.Inputqueue–collectionofprocessesonthediskthatarewaitingtobebroughtintomemorytoruntheprogram.Userprogramsgothroughseveralstepsbeforebeingrun.Sometimestheprogram(orpartsoftheprogram)maybemovedbacktodiskduringitsexecution…Briefly,someofthestepsthataprogrammustgothroughbeforebeingrunarecapturedonthenextslide.OperatingSystem.SchoolofSoftware.HUST9BindingofInstructionsandDatatoMemory(P278)Addressbindingofinstructionsanddatatomemoryaddressescanhappenatthreedifferentstages.Compiletime(编译时期):Ifmemorylocationknownapriori,absolutecodecanbegenerated;mustrecompilecodeifstartinglocationchanges.(如果内存位置已知,可生成绝对代码;如果开始位置改变,需要重新编译代码)Loadtime(装入时期):Mustgeneraterelocatablecodeifmemorylocationisnotknownatcompiletime.(如果存储位置在编译时不知道,则必须生成可重定位代码)Executiontime(执行时期):Bindingdelayeduntilruntimeiftheprocesscanbemovedduringitsexecutionfromonememorysegmenttoanother.Needhardwaresupportforaddressmaps(e.g.,baseandlimitregisters).(如果进程在执行时可以在内存中移动,则地址绑定要延迟到运行时。需要硬件对地址映射的支持,例如基址和限长寄存器)OperatingSystem.SchoolofSoftware.HUST10MultistepProcessingofaUserProgram(P279)OperatingSystem.SchoolofSoftware.HUST11绝对装入方式(AbsoluteLoadingMode)(适合“单道”)在编译时,如果知道程序将驻留在内存的什么位置,则编译程序产生绝对地址的目标代码.装入模块被装入内存后,由于程序中的逻辑地址与实际内存地址完全相同,故不需对程序和数据的地址进行修改.程序中所使用的绝对地址,既可在编译或汇编时给出,也可由程序员直接赋予。但在由程序员直接给出绝对地址时,不仅要求程序员熟悉内存的使用情况,而且一旦程序或数据被修改后,可能要改变程序中的所有地址。因此,通常是宁可在程序中采用符号地址,然后在编译或汇编时,再将这些符号地址转换为绝对地址.(8.1.4-DynamicLoading)OperatingSystem.SchoolofSoftware.HUST12JMP1424LOAD1,2224222414241024JMPiLOAD1,jjiR绝对地址符号地址OperatingSystem.SchoolofSoftware.HUST13Logicalvs.PhysicalAddressSpace(P279)Theconceptofalogicaladdressspacethatisboundtoaseparatephysicaladdressspaceiscentraltopropermemorymanagement.(逻辑地址空间的概念同物理地址空间相关联,它是正确内存管理的中心。)Logicaladdress–generatedbytheCPU;alsoreferredtoasvirtualaddress.(逻辑地址—由CPU产生;也叫做虚拟地址。)Physicaladdress–addressseenbythememoryunit.(物理地址—内存设备所读入的地址)OperatingSystem.SchoolofSoftware.HUST14LogicalandphysicaladdressesLogicalandphysicaladdressesarethesameincompile-timeandload-timeaddress-bindingschemes;logical(virtual)andphysicaladdressesdifferinexecution-timeaddress-bindingscheme.(逻辑和物理地址在编译时期和装入时期的地址绑定策略是相同的,而在执行时间的地址绑定策略是不同的。)OperatingSystem.SchoolofSoftware.HUST15Memory-ManagementUnit(MMU)(P279)Hardwaredevicethatmapsvirtualtophysicaladdress.(硬件把虚拟地址映射到物理地址)InMMUscheme,thevalueintherelocationregisterisaddedtoeveryaddressgeneratedbyauserprocessatthetimeitissenttomemory.(在MMU策略中,基址寄存器中的值在其送入内存的时候被加入到由一个用户进程所产生的每个地址中。)Theuserprogramdealswithlogicaladdresses;itneverseestherealphysicaladdresses.(用户程序所对应到的是逻辑地址,物理地址对它从来都不可见。)OperatingSystem.SchoolofSoftware.HUST16Dynamicrelocationusingarelocationregister(P280)OperatingSystem.SchoolofSoftware.HUST17DynamicLoading(动态装入)(P280)Routineisnotloadeduntilitiscalled.(程序在调用之前并不执行)Bettermemory-spaceutilization;unusedroutineisneverloaded.(更好的内存空间利用率;没有被使用的程序不被载入。)Usefulwhenlargeamountsofcodeareneededtohandleinfrequentlyoccurringcases.(当需要大量的代码来处理不经常发生的事情时是非常有用的。)Nospecialsupportfromtheoperatingsystemisrequiredimplementedthroughprogramdesign.(不需要操作系统的特别支持,通过程序设计实现)OperatingSystem.SchoolofSoftware.HUST18DynamicLinking(P281)Linkingpostponeduntilexecutiontime.(链接被推迟到执行时期)(而不是载入)Smallpieceofcode,stub,usedtolocatetheappropriatememory-residentlibraryrout

1 / 82
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功