关闭

关闭

关闭

封号提示

内容

首页 Operating System.pdf

Operating System.pdf

Operating System.pdf

上传者: chenjf92 2012-07-05 评分 0 0 0 0 0 0 暂无简介 简介 举报

简介:本文档为《Operating Systempdf》,可适用于IT/计算机领域,主题内容包含个人简介个人简介„杨公平工学博士、副教授、硕士生导师杨公平副教授师中国计算机学会高级会员中国人工智能学会机器学习专委会委员中国人工智能学会机器学习专符等。

个人简介个人简介„杨公平工学博士、副教授、硕士生导师杨公平副教授师中国计算机学会高级会员中国人工智能学会机器学习专委会委员中国人工智能学会机器学习专委会委员„机器学习及应用研究组机器学习及应用研究http:mlasdueducn„Email:gpyangsdueducn„Email:gpyangsdueducn„Phone:„Office:实验楼A座关于课程关于课程„接触OS的四类人员:OS设计者OS管理员开发人员一般用户„操作系统漫谈„操作系统漫谈„关于实验、作业、考勤„关于考核考试实验(作业考勤)„关于考核:考试实验(作业考勤)„参考书:z西电出版社汤子灜计算机操作系统z该书中文版郑扣根译„上课的重要性!教学内容教学内容„Partone:OverviewPartone:Overview„Parttwo:ProcessManagement„Partthree:MemoryManagementPtfStMt„Partfour:StorageManagement„Partfive:ProtectionandSecurity„Partfive:ProtectionandSecurityPartonePartone::OverviewOverview„Anoperatingsystemactsasanintermediarybetweentheuserofacomputerandthecomputerhardware„Thepurposeofanoperatingsystemistoprovideanenvironmentinwhichausercanexecuteprogramsinaconvenientandefficientmanner„AnoperatingsystemissoftwarethatmanagesthecomputerhardwareThehardwaremustprovideappropriatemechanismstoensurethecorrectoperationappropriatemechanismstoensurethecorrectoperationofthecomputersystemandtopreventuserprogramsfrominterferingwiththeproperoperationofthesystemfrominterferingwiththeproperoperationofthesystemPChapter:IntroductionChapter:IntroductionChapter:IntroductionChapter:Introduction„WhatOperatingSystemsDo„ComputerSystemOrganization„OperatingSystemStructure„OperatingSystemStructure„OperatingSystemOperations„PMt„ProcessManagement„MemoryManagement„StorageManagement„ProtectionandSecurityyObjectivesObjectives„Toprovideagrandtourofthemajoroperatingsystemscomponents„ToprovidecoverageofbasiccomputersystemorganizationWhatisanOperatingSystemWhatisanOperatingSystemAthttitdibt„Aprogramthatactsasanintermediarybetweenauserofacomputerandthecomputerhardwarehardware„Thepurposeofanoperatingsystemistoprovideanenvironmentinwhichausercanprovideanenvironmentinwhichausercanexecuteprogramsinaconvenientandefficientmanner操作系统的总体目标:使计算机系统方便使用convenient使计算机系统方便使用convenient使硬件能高效利用efficientP不同类型的操作系统设计目标不同„Anamazingaspectofoperatingsystemsystemsishowvariedtheyareinaccomplishingthesetasks„Mainframeoperatingsystemsaredesignedprimarilytooptimizeutilizationofhardware„PersonalComputeroperatingsystemssupportcomplexgames,businessapplications,andeverythinginbetween„Operatingsystemsforhandheldcomputersaredesignedtoprovideanenvironmentinwhichausercaneasilyinterfacewiththecomputertoexecuteprograms„Thus,someoperatingsystemsaredesignedtobeconvenient,otherstobeefficient,andotherssomecombinationofthetocombinationofthetwoPFourComponentsofaComputerSystemFourComponentsofaComputerSystemComputerSystemStructureComputerSystemStructure„Computersystemcanbedividedintofour„ComputersystemcanbedividedintofourcomponentszHardwareprovidesbasiccomputingzHardware–providesbasiccomputingresourceszOperatingsystemzOperatingsystemzApplicationprograms–definethewaysinwhichthesystemresourcesareusedtosolvewhichthesystemresourcesareusedtosolvethecomputingproblemsoftheuserszUserszUsersPeople,machines,othercomputersPOSincomputersystemOSincomputersystem„Controlsandcoordinatesuseofhardwareamongvariousapplicationsandusers„Wealsoviewacomputersystemasconsistingofhardware,software,anddataTheoperatingsystemprovidesthemeansforproperuseoftheseresourcesintheoperationofthecomputertheseresourcesintheoperationofthecomputersystem„AnoperatingsystemissimilartoagovernmentIt„AnoperatingsystemissimilartoagovernmentItperformsnousefulfunctionbyitselfItsimplyprovidesanenvironmentwithinwhichotherprovidesanenvironmentwithinwhichotherprogramscandousefulworkP研究操作系统的两种观点研究操作系统的两种观点„UserViewztheuser’sviewofthecomputervariesaccordingtotheinterfacebeingused„SystemView„SystemViewzFromthecomputer’spointofview,theoperatingsystemistheprogrammostlyoperatingsystemistheprogrammostlyintimatelyinvolvedwithhardwarePUserViewUserView„PC:theoperatingsystemisdesignedmostlyforeaseofusewithsomeattentionpaidtoperformanceandnonepaiduse,withsomeattentionpaidtoperformanceandnonepaidtoresourceutilization„Mainframeorminicomputer:Theoperatingsystemin„Mainframeorminicomputer:TheoperatingsysteminsuchcasesisdesignedtomaximizeresourceutilizationtoassurethatallavailableCPUtime,memory,andIOareusedefficientlyandthatnoindividualusertakesmorethanherfairshareUserViewUserView„Workstation:theiroperatingsystemisdesignedtocompromisebetweenindividualusabilityandresourcecompromisebetweenindividualusabilityandresourceutilization„Handheldcomputers:Theiroperatingsystemsare„Handheldcomputers:Theiroperatingsystemsaredesignedmostlyforindividualusability,butperformanceperamountofbatterylifeisimportantaswell„Embeddedcomputers:havelittleornouserview,aredesignedprimarilytorunwithoutuserinterventionSystemViewSystemView„OSisaresourceallocatorOSisaresourceallocatorzManagesallresourceszDecidesbetweenconflictingrequestsforefficientandzDecidesbetweenconflictingrequestsforefficientandfairresourceuseztheoperatingsystemmustdecidehowtoallocateztheoperatingsystemmustdecidehowtoallocatethemtospecificprogramsanduserssothatitcanoperatethecomputersystemefficientlyandfairlyoperatethecomputersystemefficientlyandfairly„OSisacontrolprogramzControlsexecutionofprogramstopreventerrorsandzControlsexecutionofprogramstopreventerrorsandimproperuseofthecomputerPOperatingSystemDefinitionOperatingSystemDefinition„NouniversallyaccepteddefinitionOtititbthffbl„Operatingsystemsexistbecausetheyofferareasonablewaytosolvetheproblemofcreatingausablecomputingsystemsystem„Thefundamentalgoalofcomputersystemsistoexecuteuserprogramsandtomakesolvinguserproblemseasieruserprogramsandtomakesolvinguserproblemseasier„Towardthisgoal,computerhardwareisconstructedSincebarehardwarealoneisnotparticularlyeasytousebarehardwarealoneisnotparticularlyeasytouse,applicationprogramsaredeveloped„Theseprogramsrequirecertaincommonoperationssuch„Theseprogramsrequirecertaincommonoperations,suchasthosecontrollingtheIOdevicesThecommonfunctionsofcontrollingandallocatingresourcesarethenbroughtgggtogetherintoonepieceofsoftware:theoperatingsystemPOperatingSystemDefinition(Cont)OperatingSystemDefinition(Cont)„“Theoneprogramrunningatalltimesonthecomputer”isthekernelEverythingelseiseitherasystemprogram(shipswiththeoperatingsystem)oranapplicationprogramAmorecommondefinitionAmorecommondefinition„ThematterofwhatconstitutesanoperatingsystemhasbecomeincreasinglyimportantIntheUnitedStatesbecomeincreasinglyimportantIn,theUnitedStatesDepartmentofJusticefiledsuitagainstMicrosoft,inessenceclaimingthatMicrosoftincludedtoomuchfunctionalityinitsclaimingthatMicrosoftincludedtoomuchfunctionalityinitsoperatingsystemsandthuspreventedapplicationvendorsfromcompetingForexample:IEwebbrowser„操作系统是一组控制和管理计算机硬件和软件资源、合理地对各类作业进行调度以及方便用户的程序的集合。ComputerSystemOrganizationComputerSystemOrganization„ComputersystemoperationzOneormoreCPUs,devicecontrollersconnectthroughcommonbusprovidingaccesstosharedmemoryzConcurrentexecutionofCPUsanddevicescompetingformemorycyclesPComputerStartupComputerStartup„bootstrapprogramisloadedatpoweruporrebootzTypicallystoredinROMorEPROM,generallyknownasfirmwarezInitializatesallaspectsofsystemzLoadsoperatingsystemkernelandstartsexecutionComputerComputerSystemOperationSystemOperation„IOdevicesandtheCPUcanexecuteconcurrently„Eachdevicecontrollerisinchargeofaparticulardevicetype„Eachdevicecontrollerhasalocalbuffer„CPUmovesdatafromtomainmemorytofromlocalbuffers„IOisfromthedevicetolocalbufferofcontroller„DevicecontrollerinformsCPUthatithasfinished„DevicecontrollerinformsCPUthatithasfinisheditsoperationbycausinganinterruptPCommonFunctionsofInterruptsCommonFunctionsofInterrupts„Interrupttransferscontroltotheinterruptserviceroutinegenerally,throughtheinterruptvector,whichcontainstheaddressesofalltheserviceroutinesroutines„Interruptarchitecturemustsavetheaddressoftheinterruptedinstructioninterruptedinstruction„Incominginterruptsaredisabledwhileanotherinterruptisbeingprocessedtopreventalostinterruptisbeingprocessedtopreventalostinterrupt„Atrapisasoftwaregeneratedinterruptcaused„Atrapisasoftwaregeneratedinterruptcausedeitherbyanerrororauserrequest„Anoperatingsstemisinterrptdrien„AnoperatingsystemisinterruptdrivenInterruptHandlingInterruptHandling„TheoperatingsystempreservesthestateoftheCPUbystoringregistersandtheprogramcounter„Determineswhichtypeofinterrupthasoccurred:zpollingzvectoredinterruptsystemzvectoredinterruptsystem„SeparatesegmentsofcodedeterminewhatactionshouldbetakenforeachtypeofinterruptshouldbetakenforeachtypeofinterruptInterruptTimelineInterruptTimelineStorageStructure„Computerprogramsmustbeinmainmemory(alsocalledrandomaccessmemoryorRAM)tobeexecutedMainrandomaccessmemoryorRAM)tobeexecutedMainmemoryistheonlylargestoragearea(millionstobillionsofbytes)thattheprocessorcanaccessdirectly„Atypicalinstructionexecutioncycle,asexecutedonasystemwithavonNeumannarchitecture,firstfetchesaninstructionfrommemoryandstoresthatinstructionintheinstructionregisterTheinstructionisthendecodedandmaycauseoperandstobefetchedfrommemoryandstoredmaycauseoperandstobefetchedfrommemoryandstoredinsomeinternalregister„mostcomputersystemsprovidesecondarystorageasan„mostcomputersystemsprovidesecondarystorageasanextensionofmainmemoryThemainrequirementforsecondarystorageisthatitbeabletoholdlargequantitiessecondarystorageisthatitbeabletoholdlargequantitiesofdatapermanentlyPStorageStorageDeviceHierarchyDeviceHierarchyIOStructureIOStructure„AfterIOstarts,controlreturnstouserprogramonlyuponIOltiIOcompletionzWaitinstructionidlestheCPUuntilthenextinterrupt(f)zWaitloop(contentionformemoryaccess)zAtmostoneIOrequestisoutstandingatatime,nosimultaneousIOprocessingsimultaneousIOprocessingPIOStructureIOStructure„AfterIOstarts,controlreturnstouserprogramwithoutitifIOltiwaitingforIOcompletionzSystemcall–requesttotheoperatingsystemtoallowusertowaitforIOcompletionusertowaitforIOcompletionzDevicestatustablecontainsentryforeachIOdeviceindicatingitstype,address,andstateindicatingitstype,address,andstatezOperatingsystemindexesintoIOdevicetabletodeterminedevicestatusandtomodifytableentrytoyyincludeinterruptTwoIOMethodsTwoIOMethodsSynchronousAsynchronousDeviceDeviceStatusTableStatusTableDirectMemoryAccessStructureDirectMemoryAccessStructure„UsedforhighspeedIOdevicesabletotransmitinformationatclosetomemoryspeeds„DevicecontrollertransfersblocksofdatafrombufferstoragedirectlytomainmemorywithoutCPUintervention„Onlyoneinterruptisgeneratedperblock,ratherthantheoneinterruptperbytePOperatingSystemStructureOperatingSystemStructure„Multiprogrammingneededforefficiency„MultiprogrammingneededforefficiencyzSingleusercannotkeepCPUandIOdevicesbusyatalltimesyzMultiprogrammingorganizesjobs(codeanddata)soCPUalwayshasonetoexecutezAsubsetoftotaljobsinsystemiskeptinmemoryzOnejobselectedandrunviajobschedulingzWhenithastowait(forIOforexample),OSithtthjbswitchestoanotherjobPMemoryLayoutforMultiprogrammedSystemMemoryLayoutforMultiprogrammedSystemOperatingSystemStructureOperatingSystemStructure„Multiprogrammedsystemsprovideanenvironmentinwhichthevarioussystemresources(forexample,CPU,memory,andperipheraldevices)areutilizedeffectively,buttheydonotprovideforuserinteractionwiththebuttheydonotprovideforuserinteractionwiththecomputersystem„Timesharing(multitasking)islogicalextensioninwhich„Timesharing(multitasking)islogicalextensioninwhichCPUswitchesjobssofrequentlythatuserscaninteractwitheachjobwhileitisrunning,creatinginteractivewitheachjobwhileitisrunning,creatinginteractivecomputing„Asthesystemswitchesrapidlyfromoneusertothenext,„Asthesystemswitchesrapidlyfromoneusertothenext,eachuserisgiventheimpressionthattheentirecomputersystemisdedicatedtohisuse,eventhoughitisbeingsharedamongmanyusersP带来的问题带来的问题„Jobscheduling„CPUscheduling„Memorymanagement„Memorymanagement„FilesystemDiskmanagementyg„provideamechanismforprotectingresourcesfiitfrominappropriateuse„providemechanismsforjobsynchronizationpodeecassojobsycoatoandcommunicationthtjbdtttki„ensurethatjobsdonotgetstuckinadeadlock,foreverwaitingforoneanotherPOperatingOperatingSystemOperationsSystemOperations„ModernoperatingsystemsareinterruptdrivenIftherearenoprocessestoexecute,noIOdevicestoservice,andnouserstowhomtorespondanoperatingsystemwillsitquietlyrespond,anoperatingsystemwillsitquietly,waitingforsomethingtohappen„Eventsarealmostalwayssignaledbythe„Eventsarealmostalwayssignaledbytheoccurrenceofaninterruptoratrap„Atrap(oranexception)isasoftwaregenerated„Atrap(oranexception)isasoftwaregeneratedinterruptcausedeitherbyanerror(forexample,divisionbyzeroorinvalidmemoryaccess)orbyayy)yspecificrequestfromauserprogramthatanoperatingsystemservicebeperformedPOperatingOperatingSystemOperationsSystemOperations„Sincetheoperatingsystemandtheuserssharethehardwareandsoftwareresourcesofthecomputersystem,weneedtomakesurethatanerrorinauserprogramcouldcauseproblemsonlyfortheoneprogramcouldcauseproblemsonlyfortheoneprogramthatwasrunning„Withsharingmanyprocessescouldbeadversely„Withsharing,manyprocessescouldbeadverselyaffectedbyabuginoneprogramForexample,ifaprocessgetsstuckinaninfiniteloop,thisloopcouldprocessgetsstuckinaninfiniteloop,thisloopcouldpreventthecorrectoperationofmanyotherprocessesOperatingOperatingSystemOperationsSystemOperations„Moresubtleerrorscanoccurinamultiprogrammingsystem,whereoneerroneousprogrammightmodifyanotherprogram,thedataofanotherprogram,oreventheoperatingsystemitselfeventheoperatingsystemitself„Withoutprotectionagainstthesesortsoferrors,eitherthecomputermustexecuteonlyoneprocessatatimethecomputermustexecuteonlyoneprocessatatimeoralloutputmustbesuspectAproperlydesignedoperatingsystemmustensurethatanincorrect(oroperatingsystemmustensurethatanincorrect(ormalicious)programcannotcauseotherprogramstoexecuteincorrectlyDualDualmodeoperationmodeoperation„Inordertoensuretheproperexecutionoftheoperatingsystem,wemustbeabletodistinguishbetweentheexecutionofoperatingsystemcodeanduserdefinedanduserdefined„DualmodeoperationallowsOStoprotectitselfandothersystemcomponentsandothersystemcomponentszkernelmode()andUsermode()zModebitprovidedbyhardwarezProvidesabilitytodistinguishwhensystemisrunningusercodeorkernelcodePTransitionfromUsertoKernelModeTransitionfromUsertoKernelMode„Whenthecomputersystemisexecutingonbehalfofauserapplication,thesystemisinusermodeHowever,whenauserapplicationrequestsaservicefromtheoperatingsystem(viaasystemservicefromtheoperatingsystem(viaasystemcall),itmusttransitionfromusertokernelmodetofulfilltherequestfulfilltherequestTransitionfromUsertoKernelModeTransitionfromUsertoKernelMode„Atsystemboottime,thehardwarestartsinkernelmodeTheoperatingsystemisthenloadedandstartsuserapplicationsinusermodeWheneveratraporinterruptoccursthehardwareswitchestraporinterruptoccurs,thehardwareswitchesfromusermodetokernelmode(thatis,changesthestateofthemodebitto)Thus,wheneverthethestateofthemodebitto)Thus,whenevertheoperatingsystemgainscontrolofthecomputer,itisinkernelmodeThesystemalwaysswitchestousermode(bysettingthemodebitto)beforepassingcontroltoauserprogramTransitionfromUsertoKernelModeTransitionfromUsertoKernelMode„ThedualmodeofoperationprovidesuswiththemeansforprotectingtheoperatingsystemfromerrantusersanderrantusersfromoneanotherWeaccomplishthisprotectionbydesignatingWeaccomplishthisprotectionbydesignatingsomeofthemachineinstructionsthatmaycauseharmasprivilegedinstructionsharmasprivilegedinstructions„ThehardwareallowsprivilegedinstructionstobeexecutedonlyinkernelmodeexecutedonlyinkernelmodeTransitionfromUsertoKernelModeTransitionfromUsertoKernelMode„TheinstructiontoswitchtousermodeisanexampleofaprivilegedinstructionSomeotherexamplesincludeIOcontrol,timermanagement,andinterruptmanagementandinterruptmanagement„Systemcallsprovidethemeansforauserprogramtoasktheoperatingsystemtoperformprogramtoasktheoperatingsystemtoperformtasksreservedfortheoperatingsystemontheuserprogram'sbehalfuserprogramsbehalfTimerTimer„WemustensurethattheoperatingsystemmaintainscontrolovertheCPUWemustpreventauserprogramcontrolovertheCPUWemustpreventauserprogramfromgettingstuckinaninfiniteloopornotcallingsystemservicesandneverreturningcontroltotheoperatingsystem„Toaccomplishthisgoal,wecanuseatimer„AtimercanbesettointerruptthecomputerafteraspecifiedperiodzTheoperatingsystemsetsthecounterzEverytimetheclockticks,thecounterisdecrementedEverytimetheclockticks,thecounterisdecrementedzWhenthecounterreaches,aninterruptoccurs

用户评论(0)

0/200

精彩专题

上传我的资料

每篇奖励 +2积分

资料评价:

/49
仅支持在线阅读

意见
反馈

立即扫码关注

爱问共享资料微信公众号

返回
顶部