版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
操作系统原理及应用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设计操作系统时采用的模块化内核方法和分层方法在那些方面类似?哪些方面不同?作业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小结(1/2)操作系统概念(管理各种资源、支持程序运行、方便用户使用的程序集)操作系统的基本目标(方便性与高效性)引导程序、中断、中断处理程序、中断向量存储结构:内存(小、易失)、二级存储(大、非易失)、分层结构I/O结构:设备控制器(本地缓冲)、DMA硬件保护:双重模式操作、特权指令、I/O保护、内存保护、CPU保护Part1小结(2/2)操作系统的发展(大型机(无OS、批处理、多道程序设计(并发性、共享性、虚拟性、异步性)、分时)——桌面——并行(紧耦合)——分布式(松耦合,集群)——专用(实时、手持))操作系统的功能:进程(CPU)管理、内存管理、文件管理、磁盘管理、I/O管理、用户接口操作系统的服务:程序执行、I/O操作、文件系统操作、通信、错误检测与处理、资源分配、统计、保护操作系统的接口:用户接口(CLI、GUI)+程序接口(系统调用(参数传递、类型)、SCI、API)操作系统的结构:简单结构、分层结构(虚拟机)、微核结构(进程管理、内存管理、通信功能)、模块化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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 小型装修公司考勤制度
- 务川自治县教师考勤制度
- 大学生军训考勤制度规定
- 公司严格落实考勤制度
- 事业人员管理考勤制度
- 东浦镇中心小学考勤制度
- 学校考勤制度建设方案模板
- 二线中老年员工考勤制度
- 平时加班工时考勤制度
- 培训中心家长考勤制度范本
- 2026春统编版二年级下册道德与法治教学设计(附目录)
- 2026石嘴山市能达建设发展有限公司招聘3人笔试参考题库及答案解析
- 2025-2026学年人教PEP版(新教材)小学英语三年级下册教学计划及进度表
- 2026年-(教科版2026新教材)科学一年级下册全册教学设计-新版
- 2026届云南省普通高中学业水平选择性考试调研测试政治试题
- 2026年就业市场:挑战与机遇并存高校毕业生就业指导与策略
- 重庆科技大学《高等数学I》2025 - 2026学年第一学期期末试卷
- 《涉外法治概论》课件 杜涛 -第1-6章 涉外法治的基础理论-涉外经济管理法律制度
- 正交试验设计与数据处理课件
- 线性系统理论-郑大钟(第二版)课件
- 《杂环化学》课件
评论
0/150
提交评论