




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
操作系統(tǒng)原理及應(yīng)用Chapter2Operating-System
StructuresOperatingSystemFunctionsOperatingSystemServicesOperatingSystemInterfacesOperatingSystemStructureOperatingSystemDesignandImplementationOutlineCommonFunctionsofOSProcessManagementMainMemoryManagementFileManagementSecondary-StorageManagementI/OSystemManagementProcessManagementAprocessisaprograminexecutionSystemProcessesandUserProcessesActivitiesforprocessmanagementProcesscreationanddeletionprocesssuspensionandresumptionProvisionofmechanismsforprocesssynchronizationprocesscommunicationDeadlockhandlingMain-MemoryManagementMemoryisalargearrayofwordsorbytes,eachwithitsownaddress.ItisgenerallytheonlylargestoragedevicethattheCPUisabletoaddressandaccessdirectly.Mainmemoryisavolatilestoragedevice.Activitiesformain-memorymanagementRecordtheusageofMain-memoryAllocateanddeallocatememoryspaceasneededFileManagement(1/2)Therearedifferenttypesofphysicalmediatostoreinformation.Eachofthemhasitsowncharacteristicsandphysicalorganization.AccessspeedData-transferrateAccessmethod(sequentialorrandom)OperatingSystemprovidesauniformlogicalviewofinformationstorage,i.e.,file.Afileisacollectionofrelatedinformation(programsanddata)definedbyitscreator.ActivitiesforfilemanagementFilecreationanddeletionDirectorycreationanddeletionSupportofprimitivesformanipulatingfilesanddirectoriesMappingfilesontosecondarystorageFilebackuponstable(nonvolatile)storagemediaFileManagement(2/2)Secondary-StorageManagementSincemainmemory(primarystorage)isvolatileandtoosmalltoaccommodatealldataandprogramspermanently,thecomputersystemmustprovidesecondarystoragetobackupmainmemory.Mostmoderncomputersystemsusedisksastheprincipleon-linestoragemedium,forbothprogramsanddata.Secondary-StorageManagementActivitiesfordiskmanagementFreespacemanagementStorageallocationDiskschedulingI/OSystemManagementHidingthepeculiaritiesofspecifichardwaredevicesfromtheuserTheI/OsubsystemconsistsofAmemory-managementcomponentincludingbuffer,caching,spoolingAgeneraldevice-driverinterfaceDriversforspecifichardwaredevicesOperatingSystemFunctionsOperatingSystemServicesOperatingSystemInterfacesOperatingSystemStructureOperatingSystemDesignandImplementationOutlineOperatingSystemServices(1/2)ServicesforhelpingUsersProgramexecution–systemcapabilitytoloadaprogramintomemoryandtorunit.I/Ooperations–sinceuserprogramscannotexecuteI/Ooperationsdirectly,theoperatingsystemmustprovidesomemeanstoperformI/O.File-systemmanipulation–programcapabilitytoread,write,create,anddeletefiles.Communications–exchangeofinformationbetweenprocesses(sharedmemoryormessagepassing)Errordetection–ensurecorrectcomputingbydetectingerrorsinhardwaresorinuserprograms.ServicesforensuringsystemoperationsResourceallocation–allocatingresourcestomultipleusersormultiplejobsrunningatthesametime.Accounting–keeptrackofwhichusersusehowmuchandwhatkindsofcomputerresources.Protection–ensuringthatallaccesstosystemresourcesiscontrolledandrecordingalltheconnectionsfordetectionofbreak-ins.OperatingSystemServices(2/2)OperatingSystemFunctionsOperatingSystemServicesOperatingSystemInterfacesOperatingSystemStructureOperatingSystemDesignandImplementationOutlineInterfacestoUsersCommand-LineInterface–textcommandsBatchInterface–filesincludingsomecommandsGraphicalUserInterface–windowsystemOperatingSystemInterfaces(1/4)Command-lineInterpreter(Shell)TheprogramthatreadsandinterpretscontrolstatementsDOSOS:TwowaystoimplementcommandsInternalCommand:Thecommandinterpreteritselfcontainsthecodetoexecutethecommand.(dir,copy)ExternalCommand:Systemprogramesimplementmostcommands.(rm,fdisk,format)OperatingSystemInterfaces(2/4)Graphicaluserinterface(GUI)Desktop:Mouse-basedwindow-and-menusystemIcons,foldersMobilesystemGesturesonthetouchscreenManysystemsnowincludebothCLIandGUIinterfacesOperatingSystemInterfaces(3/4)InterfacestoProgramesSystemcallsTypicallywritteninassembly-languageinstructionsorahigh-levellanguage(CorC++)Mostlyaccessedbyprogramsviaahigh-levelApplicationProgramInterface(API)ratherthandirectsystemcalluseOperatingSystemInterfaces(4/4)ExampleofSystemCallsSystemcallsequencetocopythecontentsofonefiletoanotherfileSystemCallImplementationApplicationProgrammingInterface(API)APIfunctionsinvoketheactualsystemcallsonbehalfoftheapplicationprogrammerJustneedstoobeyAPIandunderstandwhatOSwilldoasaresultcall,mostdetailsofOSinterfacehiddenfromprogrammerbyAPIAPIsareManagedbyrun-timesupportlibrary(setoffunctionsbuiltintolibrariesincludedwithcompiler)SystemCallImplementationSystem-callInterface(SCI)Typically,anumberassociatedwitheachsystemcallSystem-callinterfacemaintainsatableindexedaccordingtothesenumbersThesystemcallinterfaceinvokesintendedsystemcallinOSkernelandreturnsstatusofthesystemcallandanyreturnvaluesDiscussionWhydouseruseAPIsratherthansystemcalls?SystemCallImplementationThreemostcommonAPIsWin32APIforWindowsPOSIXAPIforPOSIX-basedsystems(includingvirtuallyallversionsofUNIX,Linux,andMacOSX)JavaAPIfortheJavavirtualmachine(JVM)RelationshipbetweenAPI,SCI,OSStandardCLibraryExampleCprograminvokingprintf()librarycall,whichcallswrite()systemcallSystemCallParameterPassingOften,moreinformationisrequiredthansimplyidentityofdesiredsystemcallThreegeneralmethodsusedtopassparameterstotheOSSimplest:passtheparametersinregistersParametersstoredinablock,ortable,inmemory,andaddressofblockpassedasaparameterinaregister
Parametersplaced,orpushed,ontothestackbytheprogramandpoppedoffthestackbytheoperatingsystemParameterPassingviaTableTypesofSystemCallsProcesscontrolFilemanagementDevicemanagementInformationmaintenanceCommunicationsTypesofSystemCallsProcesscontrolend,abortload,executecreateandterminateprocessgetandsetprocessattributeswaitfortimewaitevent,signaleventallocateandfreememoryTypesofSystemCallsFilemanagementcreateanddeletefileopenandclosefileread,write,repositiongetandsetfileattributesDevicemanagementrequestandreleasefileread,write,repositiongetandsetdeviceattributeslogicallyattachordetachdevicesTypesofSystemCallsInformationmaintenancegetandsettimeordategetandsetsystemdatagetandsetprocess,fileordeviceattributesCommunicationscreateanddeletecommunicationconnectionsendandreceivemessagetransferstatusinformationattachordetachremotedevicesOperatingSystemFunctionsOperatingSystemServicesOperatingSystemInterfacesOperatingSystemStructureOperatingSystemDesignandImplementationOutlineOperatingSystemStructureSimpleStructureLayeredStructureVirtualMachinesMicrokernelStructureModulesSimpleStructureMS-DOSWrittentoprovidethemostfunctionalityintheleastspaceNotdividedintomodulesAlthoughMS-DOShassomestructure,itsinterfacesandlevelsoffunctionalityarenotwellseparatedMS-DOSLayerStructureOriginalUNIXTwoseparablepartsSystemsprogramsThekernel:Consistsofeverythingbelowthesystem-callinterfaceandabovethephysicalhardware,providesalargenumberoffunctionsforonelevelSimpleStructureUNIXSystemStructureLayeredStructureTheoperatingsystemisdividedintoanumberoflayers(levels),eachbuiltontopoflowerlayers.Thebottomlayer(layer0),isthehardware;thehighest(layerN)istheuserinterface.Withmodularity,layersareselectedsuchthateachusesfunctions(operations)andservicesofonlylower-levellayersLayeredOperatingSystemOS/2LayerStructureMicrokernelStructureMovesasmuchfromthekernelinto“user”spaceTypically,microkernelsprovideminimalprocessmanagement,memorymanagementandcommunicationfacilityCommunicationtakesplacebetweenusermodulesusingmessagepassingMicrokernelStructureBenefitsEasiertoextendaoperatingsystemEasiertoporttheoperatingsystemtonewarchitecturesMorereliable(lesscodeisrunninginkernelmode)MoresecureLacksPerformanceoverheadofuserspacetokernelspacecommunicationModulesMostmodernoperatingsystemsimplementkernelmodulesUsesobject-orientedapproachEachcorecomponentisseparateEachtalkstotheothersoverknowninterfacesEachisloadableasneededwithinthekernelOverall,similartolayersbutwithmoreflexibleSolarisModularApproach設(shè)計操作系統(tǒng)時采用的模塊化內(nèi)核方法和分層方法在那些方面類似?哪些方面不同?作業(yè)1VirtualMachinesAvirtualmachinetakesthelayeredapproachtoitslogicalconclusion.IttreatshardwareandtheoperatingsystemkernelasthoughtheywereallhardwareAvirtualmachineprovidesaninterfaceidenticaltotheunderlyingbarehardwareTheoperatingsystemcreatesthe“illusion”ofmultipleprocesses,eachexecutingonitsownprocessorwithitsown(virtual)memoryVirtualMachinesNon-virtualMachineVirtualMachineVirtualMachinesAdvantagesProvidingcompleteprotectionofsystemresourcesEachvirtualmachineisisolatedfromallothervirtualmachines.Thisisolation,however,permitsnodirectsharingofresources.BeingabletosharethesamehardwareyetrundifferentoperatingsystemsconcurrentlyAperfectvehicleforoperating-systemsresearchanddevelopmentSystemdevelopmentisdoneonthevirtualmachine,sodoesnotdisruptnormalsystemoperation.VMwareArchitectureJavaVirtualMachineCompiledJavaprogramsareplatform-neutralbytecodesexecutedbyaJavaVirtualMachine(JVM).JVMconsistsofclassloaderruntimeinterpreterJust-In-Time(JIT)compilersincreaseperformanceJavaVirtualMachineJavaVirtualMachineOperatingSystemFunctionsOperatingSystemServicesOperatingSystemInterfacesOperatingSystemStructureOperatingSystemDesignandImplementationOutlineWhatanOSActuallyDoes?VirtualizesthephysicalresourcesHandlesissuesrelatedtoConcurrencyStoresfilesPersistentlyOperatingSystemDesignandImplementationDesignandImplementationofOSnot“solvable”,butsomeapproacheshaveprovensuccessfulInternalstructureofdifferentOperatingSystemscanvarywidelyStartbydefininggoalsandspecificationsAffectedbychoiceofhardware,typeofsystemOperatingSystemDesignandImplementationDesigngoalsUsergoals–operatingsystemshouldbeconvenienttouse,easytolearn,reliable,safe,andfastSystemgoals–operatingsystemshouldbeeasytodesign,implement,andmaintain,aswellasflexible,reliable,error-free,andefficientOperatingSystemDesignandImplementationImportantprincipletoseparatePolicy:Whatwillbedone?Mechanism:Howtodoit?Theseparationofpolicyfrommechanismisaveryimportantprinciple,itallowsmaximumflexibilityifpolicydecisionsaretobechangedlaterOperatingSystemDesignandImplementationWrittenmostlyinCorC++Advantage—beingfareasiertoportDisadvantage—reducedspeedandincreasedstoragerequirementsSomesmallsectionsofassemblycodefordevicedriversandforsavingandrestoringthestateofregistersPart1小結(jié)(1/2)操作系統(tǒng)概念(管理各種資源、支持程序運(yùn)行、方便用戶使用的程序集)操作系統(tǒng)的基本目標(biāo)(方便性與高效性)引導(dǎo)程序、中斷、中斷處理程序、中斷向量存儲結(jié)構(gòu):內(nèi)存(小、易失)、二級存儲(大、非易失)、分層結(jié)構(gòu)I/O結(jié)構(gòu):設(shè)備控制器(本地緩沖)、DMA硬件保護(hù):雙重模式操作、特權(quán)指令、I/O保護(hù)、內(nèi)存保護(hù)、CPU保護(hù)Part1小結(jié)(2/2)操作系統(tǒng)的發(fā)展(大型機(jī)(無OS、批處理、多道程序設(shè)計(并發(fā)性、共享性、虛擬性、異步性)、分時)——桌面——并行(緊耦合)——分布式(松耦合,集群)——專用(實(shí)時、手持))操作系統(tǒng)的功能:進(jìn)程(CPU)管理、內(nèi)存管理、文件管理、磁盤管理、I/O管理、用戶接口操作系統(tǒng)的服務(wù):程序執(zhí)行、I/O操作、文件系統(tǒng)操作、通信、錯誤檢測與處理、資源分配、統(tǒng)計、保護(hù)操作系統(tǒng)的接口:用戶接口(CLI、GUI)+程序接口(系統(tǒng)調(diào)用(參數(shù)傳遞、類型)、SCI、API)操作系統(tǒng)的結(jié)構(gòu):簡單結(jié)構(gòu)、分層結(jié)構(gòu)(虛擬機(jī))、微核結(jié)構(gòu)(進(jìn)程管理、內(nèi)存管理、通信功能)、模塊化HistoryEarlyOS:JustLibrariesBatchBeyondLibraries:ProtectionSystemcallinsteadofanormalprocedurecallUsermode/KernelmodeTrap&traphandlerHistoryEraofMultiprogrammingMainfametominicomputerMultiprogrammingMemoryprotectionConcurrencyHistoryTheModernEraMinicomputer–PersonalcomputerDOS:thediskoperatingsystemLackofmemoryprotectionMacOSPainfuljobschedulingModernOSadoptthegoodfeaturesofminicomputerOS.VirtualMachineMonitorsIntroductionMotivationVirtualizingtheCPUVirtualizingtheMemoryTheInformationGapSummaryIntroductionWhatifonewantedtorundifferentoperatingsystemsonthemachineatthesametime?Virtualmachinemonitor(VMM)(alsocalledahypervisor)IBMIntroductionScene:VMMgivestheillusiontoeachrunningOSthatitcontrolsthemachineBehindthescene:VMMisincontrolofthehardware,andmustmultiplexrunningOSesacrossthephysicalresourcesofthemachine.VMMservesasanoperatingsystemforoperatingsystemsIntroductionTheOSmuststillthinkitisinteractingwiththephysicalhardware.TransparencyisamajorgoalofVMMs.IntroductiontoVMwareMarketleaderinvirtualizationtechnologyProfessorMendelRosenblum(Stanford)VirtualMachineMonitorsIntroductionMotivationVirtualizingtheCPUVirtualizingtheMemoryTheInformationGapSummaryMotivationWhyVMMs?Inhistory:IBMmainframesToday:multiplereasonsServerconsolidationApplicationsondifferentplatformsTestinganddebuggingVirtualMachineMonitorsIntroductionMotivationVirtualizingtheCPUVirtualizingtheMemoryTheInformationGapSummaryVirtualizingtheCPUBasictechnique:LimiteddirectexecutionContextswitch–MachineswitchDirectExecutionRestrictedOperationsUsermode/KernelModeInterrupt/trap,handlerSystemcall,API,SCILimitedDirectExecutionRestrictedOperationsDiscussion:WhataboutaTimerInterrupt,insteadofaSoftwareInterrupt?ContextSwitchWillbedetailedinProcessManagement.Save/restorecontext(machinestate)MachineSwitchTheVMMmustsavetheentiremachinestateofoneOS,restorethemachinestateoftheto-be-runVM,andthenjumptothePCoftheto-be-runVMandthuscompletetheswitch.TheOScanbeeitherinusermodeorkernelmode.VirtualizingtheCPUWhatifOStriestoperformaprivilegedoperation?VMMmustsomehowinterceptattemptstoperformprivilegedoperations.Discussion:WHY?Hints:whowilltakecontrolofthemachine?VirtualizingtheCPUWhatifanapplicationtriestomakeasystemcall?Interrupt/trap?Discussion:traditionalsettingwithoutvirtualizationReview:SystemCallVirtualizingtheCPUTransferscontroltoawell-definedtraphandlerwithintheoperatingsystem.ChangesthemodeoftheprocessorfromusermodetokernelmodeVirtualizingtheCPUOnavirtualizedplatform:AfteraninterruptVMMcontrolsthemachine,andthustheVMMwhohasinstalledatraphandlerthatwillfirstgetexecutedinkernelmodeBUT:VMMDOESNOTreallyknowhowtoha
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2030年中國合式放大鏡數(shù)據(jù)監(jiān)測研究報告
- 2025至2030年中國PVC地毯保護(hù)地墊數(shù)據(jù)監(jiān)測研究報告
- 郵政面試筆試題及答案
- 專題5 功和簡單機(jī)械 2021年和2022年江蘇省南通市中考物理模擬試題匯編
- 2019-2025年消防設(shè)施操作員之消防設(shè)備基礎(chǔ)知識自我檢測試卷A卷附答案
- 2019-2025年軍隊文職人員招聘之軍隊文職管理學(xué)真題練習(xí)試卷A卷附答案
- 酒店合同范本(2篇)
- 2023年黑龍江公務(wù)員《行政職業(yè)能力測驗(yàn)》試題真題及答案
- 環(huán)境保護(hù)與可持續(xù)發(fā)展知識點(diǎn)測試
- 語文課本里的經(jīng)典詩文賞析
- 課件-DeepSeek從入門到精通
- 【MOOC】理解馬克思-南京大學(xué) 中國大學(xué)慕課MOOC答案
- 醫(yī)學(xué)課件-耳穴壓豆教學(xué)課件
- 4.1.4公正性風(fēng)險評價記錄表
- 電力拖動自動控制系統(tǒng)-運(yùn)動控制系統(tǒng)(第5版)習(xí)題答案
- 關(guān)于印發(fā)《臨床輸血技術(shù)規(guī)范》的通知
- 高考語文復(fù)習(xí):虛實(shí)結(jié)合手法 課件23張
- 離婚調(diào)查取證申請書
- 家庭電路故障分析-課件
- 設(shè)備學(xué)習(xí)電子圍欄g5tk400說明書
- 外研版一起五年級英語下冊全冊教案教學(xué)設(shè)計版
評論
0/150
提交評論