Chapter2:Computer-SystemStructuresStructures沈卓炜zwshen@seueducnzwshen@seu.edu.cn四牌楼校区文正楼南205,83790819-802九龙湖校区计算机楼316(周一、周三)13390922952Chapter2:Computer-SystemStructures(6thEd)(6thEd.)CompterSstemOperationnComputerSystemOperationnI/OStructurenStorageStructureStHihnStorageHierarchynHardwareProtectionnNetworkStructureSoutheastUniversity2.2OperatingSystemConceptsComputer-SystemArchitectureCoputeSystectectueHowdoestheOStitOSgetintosystem?HdHowdowerequestfori?services?HowdoestheOSkOSknowsomethinghashd?happened?SoutheastUniversity2.3OperatingSystemConceptsComputer-SystemOperationCoputeSysteOpeatoI/OdeicesandtheCPUcaneectenI/OdevicesandtheCPUcanexecuteconcurrently.nEachdevicecontrollerisinchargeofaparticulardevicetypeparticulardevicetype.nEachdevicecontrollerhasalocalbuffer.SoutheastUniversity2.4OperatingSystemConceptsComputer-SystemOperation(Cont.)pyp()CPUmoesdatafrom/tomainmemornCPUmovesdatafrom/tomainmemoryto/fromlocalbuffersnI/Oisfromthedevicetolocalbufferofcontrollercontroller.nDevicecontrollerinformsCPUthatithasfiihdittibifinisheditsoperationbycausinganinterrupt.SoutheastUniversity2.5OperatingSystemConceptsInterruptteuptnAneventthatrequirestheattentionofthenAneventthatrequirestheattentionoftheOSisaninterrupt.TheseeventsincludethecompletionofanI/O,akeypress,arequestcompletionofanI/O,akeypress,arequestforservice,adivisionbyzeroandsoon.nInterruptsmaybegeneratedbyhardwareornInterruptsmaybegeneratedbyhardwareorsoftware.nAninterruptgeneratedbysoftware(ienAninterruptgeneratedbysoftware(i.e.,divisionby0)isusuallyreferredtoasatrap.nModernoperatingsystemsareinterruptnModernoperatingsystemsareinterruptdriven,meaningtheOSisinactiononlyifaninterruptoccurs.SoutheastUniversity2.6OperatingSystemConceptsinterruptoccurs.WhatisInterruptdriven?atsteuptdenTheOSisactivatedbyaninterruptbyaninterrupt.nTheexecutingprogramisprogramissuspended.nControlisnControlistransferredtotheOSOS.nProgramcontinueswhentheservicewhentheservicecompletesSoutheastUniversity2.7OperatingSystemConceptsInterruptTimeLineForaSingleProcessDoingOutputSoutheastUniversity2.8OperatingSystemConceptsCommonFunctionsofInterruptsCoouctosoteuptsInterrpttransferscontroltotheinterrptnInterrupttransferscontroltotheinterruptserviceroutinegenerally,throughtheinterruptvector,whichcontainstheaddressesofalltheserviceroutines.nInterruptarchitecturemustsavetheaddressoftheinterruptedinstructionoftheinterruptedinstruction.nIncominginterruptsaredisabledwhileanotherinterruptisbeingprocessedtopreventalostinterrupt.SoutheastUniversity2.9OperatingSystemConceptspreventalostinterrupt.InterruptHandlingTheoperatingsstempreseresthestateofnTheoperatingsystempreservesthestateoftheCPUbystoringregistersandtheprogramcounter.nDetermineswhichtypeofinterrupthasnDetermineswhichtypeofinterrupthasoccurred:llipollingvectoredinterruptsystemnSeparatesegmentsofcodedeterminewhatactionshouldbetakenforeachtypeofSoutheastUniversity2.10OperatingSystemConceptsactionshouldbetakenforeachtypeofinterruptI/OInterrupt/OteuptSoutheastUniversity2.11OperatingSystemConceptsI/OStructure/OStuctuenAfterI/Ostarts,controlreturnstouserprogramonlyuponI/Ocompletion.pWaitinstructionidlestheCPUuntilthenextinterruptpWaitloop(contentionformemoryaccess).)AtmostoneI/Orequestisoutstandingatatime,nosimultaneousgI/Oprocessing.SoutheastUniversity2.12OperatingSystemConceptsI/OStructure(Cont.)/OStuctue(Cot)nAfterI/Ostarts,controlreturnstouserprogramwithoutwaitingforI/Ocompletion.Systemcall–requesttotheoperatingsystemyqpgytoallowusertowaitforI/Ocompletion.Device-statustablecontainsentryforeachI/Oydeviceindicatingitstype,address,andstate.OperatingsystemindexesintoI/Odevicetablepgytodeterminedevicestatusandtomodifytableentrytoincludeinterrupt.SoutheastUniversity2.13OperatingSystemConceptsTwoI/OMethodso/OetodsSynchronousAsynchronousSoutheastUniversity2.14OperatingSystemConceptsDevice-StatusTableeceStatusabeSoutheastUniversity2.15OperatingSystemConceptsDirectMemoryAccessStructureecteoyccessStuctueUsedforhighspeedI/OdeicesabletonUsedforhigh-speedI/Odevicesabletotransmitinformationatclosetomemoryspeeds.nDevicecontrollertransfersblocksofdatanDevicecontrollertransfersblocksofdatafrombufferstoragedirectlytomainmemorywithoutCPUinterventionwithoutCPUintervention.nOnlyoneinterruptisgeneratedperblock,ratherthantheoneinterruptperbyte.SoutheastUniversity2.16OperatingSystemConceptsDirectMemoryAccessStructure(Ct)(Cont.)SoutheastUniversity2.17OperatingSystemConceptsStorageStructureStoageStuctuenMainmemory–onlylargestoragemediathattheCPUcanaccessdirectly.nSecondarystorage–extensionofmainmemorynSecondarystorageextensionofmainmemorythatprovideslargenonvolatilestoragecapacity.MtidikiidtlllttnMagneticdisks–rigidmetalorglassplatterscoveredwithmagneticrecordingmaterialDisksurfaceislogicallydividedintotracks,whicharesubdividedintosectors.aresubdividedintosectors.ThediskcontrollerdeterminesthelogicalinteractionbetweenthedeviceandthecomputerSoutheastUniversity2.18OperatingSystemConceptsinteractionbetweenthedeviceandthecomputer.Moving-HeadDiskMechanismoge