操作系统教学课件:Chapter 2 Computer-System Structures_第1页
操作系统教学课件:Chapter 2 Computer-System Structures_第2页
操作系统教学课件:Chapter 2 Computer-System Structures_第3页
操作系统教学课件:Chapter 2 Computer-System Structures_第4页
操作系统教学课件:Chapter 2 Computer-System Structures_第5页
已阅读5页,还剩33页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Chapter2:Computer-SystemStructures从OS的角度看计算机系统的结构,每个部件都有一个软件部分(controller)为了管理和应用计算机资源,OS自身应该包括哪些组件ComputerSystemOperationI/OStructureStorageStructureStorageHierarchyHardwareProtectionGeneralSystemArchitectureOSsystemcomponentsComputer-SystemArchitectureComputer-SystemArchitecture指令系统Computer-SystemOperationI/OdevicesandtheCPUcanexecuteconcurrently.Eachdevicecontrollerisinchargeofaparticulardevicetype.Eachdevicecontrollerhasalocalbuffer(缓存).CPUmovesdatafrom/tomainmemoryto/fromlocalbuffersI/Oisfromthedevicetolocalbufferofcontroller.DevicecontrollerinformsCPUthatithasfinisheditsoperationbycausinganinterrupt.CommonFunctionsofInterruptsInterrupt

(中断)transferscontroltotheinterruptserviceroutinegenerally,throughtheinterruptvector,whichcontainstheaddressesofalltheserviceroutines.Interruptarchitecturemustsavetheaddressoftheinterruptedinstruction.Incominginterruptsaredisabledwhileanotherinterruptisbeingprocessedtopreventalostinterrupt.A

trap

(陷阱)isasoftware-generatedinterruptcausedeitherbyanerrororauserrequest.Anoperatingsystemisinterruptdriven.(操作系统的运行是一种中断驱动机制)

OS

Application

&

user

hardwareOS启动后,设置好环境,设置好trap和interrupt。然后自顾自地运行有事call

OS有事发interruptInterruptHandlingTheoperatingsystempreservesthestateoftheCPUbystoringregistersandtheprogramcounter(PC).Determineswhichtypeofinterrupthasoccurred:polling(轮询)vectoredinterruptsystemSeparatesegmentsofcodedeterminewhatactionshouldbetakenforeachtypeofinterruptInterruptTimeLineForaSingleProcessDoingOutputInterruptTimeLineForaSingleProcessDoingOutput产生中断产生中断InterruptTimeLineForaSingleProcessDoingOutput产生中断产生中断中断处理中断处理I/OStructureAfterI/Ostarts,controlreturnstouserprogramonlyuponI/Ocompletion.–

synchronous同步WaitinstructionidlestheCPUuntilthenextinterruptWaitloop(contentionformemoryaccess).AtmostoneI/Orequestisoutstandingatatime,nosimultaneousI/Oprocessing.AfterI/Ostarts,controlreturnstouserprogramwithoutwaitingforI/Ocompletion.–

asynchronous异步Systemcall

–requesttotheoperatingsystemtoallowusertowaitforI/Ocompletion.Device-statustablecontainsentryforeachI/Odeviceindicatingitstype,address,andstate.OperatingsystemindexesintoI/Odevicetabletodeterminedevicestatusandtomodifytableentrytoincludeinterrupt.TwoI/OMethodsSynchronousAsynchronousDevice-StatusTableThetablecontaininganentryforeachI/Odevice,eachentryindicatesthedevice’stype,address,stateDirectMemoryAccessStructureUsedforhigh-speedI/Odevicesabletotransmitinformationatclosetomemoryspeeds.DevicecontrollertransfersblocksofdatafrombufferstoragedirectlytomainmemorywithoutCPUintervention.Onlyoninterruptisgeneratedperblock,ratherthantheoneinterruptperbyte.StorageStructureMainmemory–onlylargestoragemediathattheCPUcanaccessdirectly.Secondarystorage–extensionofmainmemorythatprovideslargenonvolatilestoragecapacity.Magneticdisks–rigidmetalorglassplatterscoveredwithmagneticrecordingmaterialDisksurfaceislogicallydividedintotracks,whicharesubdividedintosectors.Thediskcontrollerdeterminesthelogicalinteractionbetweenthedeviceandthecomputer.Moving-HeadDiskMechanismMoving-HeadDiskMechanism存储容量=磁头数×磁道(柱面)数×每道扇区数×每扇区字节数

要点:(1)硬盘有数个盘片,每盘片两个面,每个面一个磁头

(2)盘片被划分为多个扇形区域即扇区

(3)同一盘片不同半径的同心圆为磁道

(4)不同盘片相同半径构成的圆柱面即柱面

(5)信息记录可表示为:××磁道(柱面),××磁头,××扇区StorageHierarchy希望速度越快越好、价格越低越好、信息不要丢失Storagesystemsorganizedinhierarchy.SpeedCostVolatilityCaching

–copyinginformationintofasterstoragesystem;mainmemorycanbeviewedasalastcacheforsecondarystorage.Storage-DeviceHierarchy最贵CPU级几十个易失纳秒级M易失微秒级M、G毫秒级G不易失秒级T不易失CachingUseofhigh-speedmemorytoholdrecently-accesseddata.Requiresacachemanagementpolicy.Cachingintroducesanotherlevelinstoragehierarchy.Thisrequiresdatathatissimultaneouslystoredinmorethanoneleveltobeconsistent(一致性).MigrationofAFromDisktoRegisterCachecoherencyandconsistencyHardwareProtection为什么要保护?-保护的目的是让硬件公平、高效地为当前所有用户服务,不是保护起来不让用户使用保护哪些?-硬件资源怎么保护?-依赖于硬件Dual-ModeOperationI/OProtectionMemoryProtectionCPUProtectionDual-ModeOperation特权与普权Sharingsystemresourcesrequiresoperatingsystemtoensurethatanincorrectprogramcannotcauseotherprogramstoexecuteincorrectly.Providehardwaresupporttodifferentiatebetweenatleasttwomodesofoperations.1. Usermode(用户态、目态)

–executiondoneonbehalfofauser.2.

Monitormode(管态、内核态)

(alsokernelmodeorsystemmode)–executiondoneonbehalfofoperatingsystem.Dual-ModeOperation(Cont.)Modebitaddedtocomputerhardwaretoindicatethecurrentmode:monitor(0)oruser(1).Whenaninterruptorfaultoccurshardwareswitchestomonitormode.Privilegedinstructions

canbeissuedonlyinmonitormode.monitoruserInterrupt/faultsetusermodeI/OProtection-由OS掌控AllI/Oinstructionsareprivilegedinstructions.Mustensurethatauserprogramcouldnevergaincontrolofthecomputerinmonitormode(I.e.,auserprogramthat,aspartofitsexecution,storesanewaddressintheinterruptvector).UseofASystemCalltoPerformI/OMemoryProtection-OS确定私人空间Mustprovidememoryprotectionatleastfortheinterruptvectorandtheinterruptserviceroutines.Inordertohavememoryprotection,addtworegistersthatdeterminetherangeoflegaladdressesaprogrammayaccess:Baseregister

–holdsthesmallestlegalphysicalmemoryaddress.Limitregister

–containsthesizeoftherangeMemoryoutsidethedefinedrangeisprotected.UseofABaseandLimitRegisterHardwareAddressProtectionHardwareProtectionWhenexecutinginmonitormode,theoperatingsystemhasunrestrictedaccesstobothmonitoranduser’smemory.Theloadinstructionsforthebaseandlimitregistersareprivilegedinstructions.CPUProtection-工作与休息Timer(定时器)

–interruptscomputerafterspecifiedperiodtoensureoperatingsystemmaintainscontrol.Timerisdecrementedeveryclocktick.Whentimerreachesthevalue0,aninterruptoccurs.Timercommonlyusedtoimplementtimesharing.Timealsousedtocomputethecurrenttime.Load-timerisaprivilegedinstruction.NetworkStructureLocalAreaNetworks(LAN)WideAreaNetworks(WAN)LocalAreaNetworkStructureWideAreaNetworkStructureOSsystemcomponentsCPU-ProcessmanagementMemory-Main-memorymanagementDisk-FilemanagementStoragesystem-Secondary-storagemanagementI/O-I/O-systemmanagement不同计算机连起来

-Networking保护和安全

-Protectionsystem计算机为人所用

-Userinterfacesystemsummary从OS角度看计算机系统硬件保护双模态、定时器OS自身的系统组件作业1.Howdoesthedistinctionbetweenmonitormodeandusermodefunctionasarudimentaryformofprotection(security)system?2.

Whatarethedifferencesbetweenatrapandaninterrupt?Whatistheuseofeachfunction?3.Whichofthefol

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论