版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
ComputerOrganization&Architecture
Chapter3–BasicInput/OutputContentofthislecture3.1AccessingI/ODevices3.2Interrupts8.4DirectMemoryAccessSummaryAccessingI/ODevices(1)I/ODevicesLinktotheoutsideworldTypesHumanreadableMonitorPrinterMachinereadableDiskCDROMScannerCommunicationModemNetworkInterfaceCard(NIC)AccessingI/ODevices(2)ExamplesofI/ODevicesDevice Input/Output DateRate(Kbytes/s)Keyboard Input 0.01Mouse Input 0.02Voiceinput(microphone)Input 0.02Scanner Input 200Voiceoutput(speaker) Output 0.5Dot-matrixprinter Output 1Laserprinter Output 100Graphicsdisplay Output 30,000Localareanetwork Input/output 200–20,000Opticaldisk Storage(I/O) 500Magnetictape Storage(I/O) 2,000Magneticdisk Storage(I/O) 2,000AccessingI/ODevices(3)AccessingI/ODevices(4)AccessingI/ODevices(ctd.)AccessingI/ODevices(5)AccessingI/ODevices(6)I/ODeviceInterfaceTheaddressdecoder,thedataandstatusregisters,andthecontrolcircuitryconstitutethedevice’sinterfacecircuit.AccessingI/ODevices(7)I/OInterface(ctd.)FunctionsofinterfaceDevicecommunicationControl:DeterminewhetherdevicewillsendorreceivedataData:ActualdatatransferredStatus:Deviceisready,DataisavailablefortransferorerrorDatabufferingMusthandlevaryingdataratesfrommemoryandI/OdeviceBufferdatasothatnoonegetstieddownErrordetectionReporttoCPUmechanicalfailuree.g.paperjamReportdatatransmissionerrorAccessingI/ODevices(8)I/OInterface(ctd.)Functionsofinterface(ctd.)ControlandSignalingCo-ordinatesdatatransferbasedoncommunicationmethodwiththeprocessorCommunicationwithCPUProgrammeda.k.aPollingInterruptdrivenDirectMemoryAccess(DMA)AccessingI/ODevices(9)AddressingModesofI/ODevices(Interface)Memory-mappedI/OI/Odevicesandthememorysharethesameaddressspace.Somememoryaddressvaluesareusedtorefertoperipheraldeviceinterfaceregisters.I/Olooksjustlikememoryread/writeExample
LoadR2,DATAINDATAINistheaddressoftheinputbufferassociatedwiththekeyboard.AdvantageAnymachineinstructionthatcanaccessmemorycanbeusedtotransferdatatoorfromanI/Odevice.AccessingI/ODevices(10)AddressingModesofI/ODevices(Interface)(ctd.)Memory-mappedI/O(ctd.)DisadvantageValuablememoryaddressspaceisusedup.IsolatedI/OUsespecialInandOutinstructionstoperformI/Otransfers.AdvantageI/Odevicesdealwithfewaddresslines.NoteAseparateI/OaddressspacedoesnotnecessarilymeanthattheI/Oaddresslinesarephysicallyseparatefromthememoryaddresslines.AccessingI/ODevices(11)Program-controlledI/OCPUexecutesaprogramthatcommunicateswithI/OmoduleRead/writecommandsSensingstatusTransferringdataCPUwaitsforI/OmoduletocompleteoperationDisadvantageisthatitwastesCPUtimeExample:Considerataskthatreadscharacterstypedonakeyboard,storesthesedatainthememory,anddisplaysthesamecharactersonadisplayscreen.AccessingI/ODevices(12)Program-controlledI/O(ctd.)Example(ctd.)ThedifferenceinspeedbetweentheprocessorandI/Odevicescreatestheneedformechanismstosynchronizethetransferofdatabetweenthem.Onoutput,theprocessorsendsthefirstcharacterandthenwaitsforasignalfromthedisplaythatthecharacterhasbeenreceived.Itthensendsthesecondcharacter,andsoon.Oninput,theprocessorwaitsforasignalindicatingthatacharacterkeyhasbeenstruckandthatitscodeisavailableinsomebufferregisterassociatedwiththekeyboard.Thentheprocessorproceedstoreadthatcode.AccessingI/ODevices(13)Program-controlledI/O(ctd.)Example(ctd.)SignalingProtocolforI/ODevicesAssumethattheI/Odeviceshaveawaytosenda‘ready’signaltotheprocessorForkeyboard,indicatescharactercanberead
soprocessorusesLoadtoaccessdataregisterFordisplay,indicatescharactercanbesentsoprocessorusesStoretoaccessdataregisterThe‘ready’signalineachcaseisastatusflag
instatusregisterthatispolledbyprocessorAccessingI/ODevices(14)AccessingI/ODevices(15)Program-controlledI/O(ctd.)Example(ctd.)Keyboard&DisplayInterfaceRegisterOrganizationAccessingI/ODevices(16)Program-controlledI/O(ctd.)Example(ctd.)WaitLoopforPollingI/OStatusProgram-controlledI/Oimplementedwithawaitloopforpollingkeyboardstatusregister:
READWAIT: LoadByte R4,KBD_STATUS
And R4,R4,#2
Branch_if_[R4]0READWAIT
LoadByte R5,KBD_DATAKeyboardcircuitplacescharacterinKBD_DATAandsetsKINflaginKBD_STATUSCircuitclearsKINflagwhenKBD_STATUSreadAccessingI/ODevices(17)Program-controlledI/O(ctd.)Example(ctd.)WaitLoopforPollingI/OStatusSimilarwaitloopfordisplaydevice:
WRITEWAIT: LoadByte R4,DISP_STATUS
And R4,R4,#4
Branch_if_[R4]0WRITEWAIT
StoreByte R5,DISP_DATADisplaycircuitsetsDOUTflaginDISP_STATUSafterpreviouscharacterhasbeendisplayedCircuitautomaticallyclearsDOUTflag
whenDISP_STATUSregisterisreadAccessingI/ODevices(18)AccessingI/ODevices(19)Program-controlledI/O(ctd.)Example(ctd.)RISCProgramRISC-andCISC-styleI/OProgramsAccessingI/ODevices(20)Program-controlledI/O(ctd.)Example(ctd.)CISCProgramRISC-andCISC-styleI/OProgramsInterrupts(1)WhatisInterrupt?Aninterruptisaneventthatcausestheprocessortostopitscurrentprogramexecutionandswitchtoperforminganinterruptserviceroutine.AdvantagesofInterruptOvercomesCPUwaitingNorepeatedCPUcheckingofdeviceI/OmoduleinterruptswhenreadyInterrupts(2)Interrupts(3)Interrupts(4)Example3.1(ctd.)Interrupts(5)ConceptsofInterruptInterruptRequestSignalAsignalthatanI/Odevicesendstotheprocessorthroughoneofthebuscontrollines.InterruptAcknowledgeSignalTheCPUissuethesignaltoacknowledgestheinterruptInterrupts(6)ConceptsofInterrupt(ctd.)Interrupt-ServiceRoutine(InterruptHandler)Theroutineexecutedinresponsetoaninterruptrequestiscalledtheinterrupt-serviceroutine.InterruptLatencyThedelaybetweenthetimeaninterruptrequestisreceivedandthestartofexecutionoftheinterrupt-serviceroutine.Interrupts(7)ConceptsofInterrupt(ctd.)Differencebetweensubroutineandinterrupt-serviceroutineAsubroutineperformsafunctionrequiredbytheprogramfromwhichitiscalled.Assuch,potentialchangestostatusinformationandcontentsofregistersareanticipated.Aninterrupt-serviceroutinemaynothaveanyrelationtotheportionoftheprogrambeingexecutedatthetimetheinterruptrequestisreceived.Therefore,beforestartingexecutionoftheinterruptserviceroutine,statusinformationandcontentsofprocessorregistersthatmaybealteredinunanticipatedwaysduringtheexecutionofthatroutinemustbesaved.Thissavedinformationmustberestoredbeforeexecutionoftheinterruptedprogramisresumed.Interrupts(8)InterruptProcessingWhenaninterruptoccurs(andisaccepted),theexecutionofthecurrentprogramissuspendedMustsavePC,RegistersinProcessControlBlock(PCB)InterruptserviceroutineexecutestoservicetheinterruptFlowchart(nextpage)Interrupts(9)InterruptProcessing(ctd.)Interrupts(10)EnablingandDisablingInterruptsEnablinganddisablinginterruptsarefundamentaltoallcomputersTheinterruptionofprogramexecutionmustbecarefullycontrolledbecauseinterruptscanarriveatanytime,theymayalterthesequenceofeventsfromthatenvisagedbytheprogrammer.Itmaybenecessarytoguaranteethataparticularsequenceofinstructionsisexecutedtotheendwithoutinterruptionbecausetheinterruptserviceroutinemaychangesomeofthedatausedbytheinstructionsinquestion.Interrupts(11)EnablingandDisablingInterrupts(ctd.)InterruptControlatProcessorEndSetInterrupt-enablebitintheProgramStatusregisterSuitableforasimpleprocessorwithonlyoneinterrupt-requestline.Havetheprocessorautomaticallydisableinterrupts(cleartheInterrupt-enablebit)beforestartingtheexecutionoftheinterrupt-serviceroutine.(IE=0)WhenaReturn-from-interruptinstructionisexecuted,thecontentsofthePSarerestoredfromthestack,settingtheInterrupt-enablebitbackto1.(IE=1)Interrupts(12)EnablingandDisablingInterrupts(ctd.)InterruptControlatI/ODeviceEndItisimportanttoensurethatinterruptrequestsaregeneratedonlybythoseI/Odevicesthattheprocessoriscurrentlywillingtorecognize.Needamechanismintheinterfacecircuitsofindividualdevicestocontrolwhetheradeviceisallowedtointerrupttheprocessor.Aninterrupt-enablebitinacontrolregisterdetermineswhetherthedeviceisallowedtogenerateaninterruptrequest.Interrupts(13)EnablingandDisablingInterrupts(ctd.)InterruptControlatI/ODeviceEnd(ctd.)Interrupts(14)MultipleDevicesInterruptSystemDesignIssuesHowdoyouidentifythemoduleissuingtheinterrupt?Howtheprocessorobtainthestartingaddressoftheappropriateroutineofdifferentdevices?—IdentifyInterruptSourceShouldadevicebeallowedtointerrupttheprocessorwhileanotherinterruptisbeingserviced?—Multi-levelInterruptHowshouldtwoormoresimultaneousinterruptrequestsbehandled?—SimultaneousInterruptInterrupts(15)Interrupts(16)IdentifyInterruptSource(ctd.)CommonInterrupt-requestLine(ctd.)Polling(NonvectoredInterrupt)(ctd.)Interrupts(17)IdentifyInterruptSource(ctd.)
CommonInterrupt-requestLine(ctd.)VectoredInterruptAninterruptschemewheretheinterruptingdeviceidentifiesitselfwhengeneratinginterrupts.InterruptVectorAninterruptvectoristhememoryaddressofaninterrupthandler,oranindexintoanarraycalledaninterruptvectortableordispatch
table.Interruptvectortablescontainthememoryaddressesofinterrupthandlers.Interrupts(18)IdentifyInterruptSource(ctd.)
CommonInterrupt-requestLine(ctd.)VectoredInterrupt(ctd.)
Whenadevicesendsaninterruptrequest,theprocessormaynotreadytoreceivetheinterrupt-vectorcodeimmediately.Whentheprocessorisreadytoreceivetheinterrupt-vectorcode,itactivatestheinterrupt-acknowledgeline,INTATheI/Odevicerespondsbysendingitsinterrupt-vectorcodeandturningofftheINTRsignal.Interrupts(19)Multi-levelInterrupt
Single-levelInterruptWhetheronedeviceorseveralI/Odevices,interruptsshouldbedisabledduringtheexecutionofaninterrupt-serviceroutine.Multi-levelInterrupt(InterruptNesting)Itisnecessarytoacceptanotherdeviceinterruptduringtheexecutionofaninterrupt-serviceroutineforadevice.I/Odevicesareorganizedinaprioritystructure.Aninterruptrequestfromahigh-prioritydeviceshouldbeacceptedwhiletheprocessorisservinganotherrequestfromalower-prioritydevice.Interrupts(20)Multi-levelInterrupt(ctd.)MultipleInterrupt(ctd.)Multi-LevelPriorityAssignapriorityleveltotheprocessorthatcanbechangedunderprogram(privilegedinstructions)control.Thepriorityleveloftheprocessoristhepriorityoftheprogramthatiscurrentlybeingexecuted.Theprocessoracceptsinterruptsonlyfromdevicesthathaveprioritieshigherthanitsown.Atthetimetheexecutionofaninterrupt-serviceroutineforsomedeviceisstarted,thepriorityoftheprocessorisraisedtothatofthedevice.
Theprocessor’sprioritycanbeencodedinafewbitsoftheprocessorstatusregister.Interrupts(21)Multi-levelInterrupt(ctd.)Multi-levelInterrupt(ctd.)Multi-LevelPriority(ctd.)Implementationofinterruptpriorityusingindividualinterrupt-requestandacknowledgelinesInterrupts(22)SimultaneousInterruptIndividualdevicehasindividualinterrupt-requestandacknowledgelinesTheprocessorsimplyacceptstherequesthavingthehighestpriority.Itallowstheprocessortoacceptinterruptrequestsfromsomedevicesbutnotfromothers,dependingupontheirpriorities.Severaldevicesshareoneinterrupt-requestlineSoftwarePollDaisyChain(HardwarePoll)PriorityGroupInterrupts(23)SimultaneousInterrupt(ctd.)SoftwarePollTheprocessorpollthestatusregisteroftheI/Odevice.Priorityisdeterminedbytheorderinwhichthedevicesarepolled.DaisyChainInthedaisychainarrangement,thedevicethatiselectricallyclosesttotheprocessorhasthehighestpriority.Theseconddevicealongthechainhassecondhighestpriority,andsoon.ProcessorDevice2INTRINTADevicenDevice1Interrupts(24)SimultaneousInterrupt(ctd.)PriorityGroupcircuitDeviceDevicePriorityarbitrationProcessorDeviceDeviceINTR1INTRpINTA1INTApInterrupts(25)ProcessorControlRegistersProcessorStatusRegister(PS)IPSregisteriswherePSisautomaticallysavedwhenaninterruptrequestisrecognizedIENABLEregisterallowstheprocessortoselectivelyrespondtoindividualI/Odevices.HasonebitperdeviceIPENDINGhasonebitperdevicetoindicateifinterruptrequesthasnotyetbeenservicedInterrupts(26)ProcessorControlRegisters(ctd.)Interrupts(27)ProcessorControlRegisters(ctd.)AccessingControlRegistersUsespecialMoveinstructionsthattransfervaluestoandfromgeneral-purposeregistersTransferpendinginterruptrequeststoR4:
MoveControl R4,IPENDINGTransfercurrentprocessorIEsettingtoR2:
MoveControl R2,PSTransferdesiredbitpatterninR3toIENABLE:
MoveControl IENABLE,R3Interrupts(28)ExamplesofInterruptProgramsExample3.2Letusconsideragainthetaskofreadingalineofcharacterstypedonakeyboard,storingthecharactersinthemainmemory,anddisplayingthemonadisplaydevice.Now,wewilluseinterruptswiththekeyboard,butpollingwiththedisplay.Assumethataspecificmemorylocation,ILOC,isdedicatedfordealingwithinterrupts,andthatitcontainsthefirstinstructionoftheinterrupt-serviceroutine.Interrupts(29)ExamplesofInterruptPrograms(ctd.)Example3.2(ctd.)Wheneveraninterruptrequestarrivesattheprocessor,andprocessorinterruptsareenabled,theprocessorwillautomatically:Savethecontentsoftheprogramcounter,eitherinaprocessorregisterthatholdsthereturnaddressorontheprocessorstack.SavethecontentsofthestatusregisterPSbytransferringthemintotheIPSregister,andcleartheIEbitinthePS.LoadtheaddressILOCintotheprogramcounterInterrupts(30)ExamplesofInterruptPrograms(ctd.)Interrupts(31)ExamplesofInterruptPrograms(ctd.)Interrupts(32)ExamplesofInterruptPrograms(ctd.)Example3.3Supposeaprogramneedstodisplayapageoftextstoredinthememory.Thiscanbedonebyhavingtheprocessorsendacharacterwheneverthedisplayinterfaceisready,whichmaybeindicatedbyaninterruptrequest.Assumethatboththedisplayandthekeyboardareusedbythisprogram,andthatbothareenabledtoraiseinterruptrequests.Interrupts(33)ExamplesofInterruptPrograms(ctd.)Example3.3(ctd.)Touseinterruptsforbothkeyboard&display,callsubroutinesfromILOCserviceroutineServiceroutinereadsIPENDINGregisterCheckswhichdevicebit(s)is(are)set
todeterminewhichsubroutine(s)tocallServiceroutinemustsave/restoreLinkregisterAlsoneedseparatepointervariabletoindicate
outputcharacterfornextdisplayinterruptInterrupts(34)ExamplesofInterruptPrograms(ctd.)DirectMemoryAccess(1)InterruptdrivenandprogrammedI/OrequireactiveCPUinterventionTransferrateislimitedCPUistiedupSolution:DMAUsedforhigh-speedblocktransfersbetweenadeviceandmemoryDuringthetransfer,theCPUisnotinvolvedTypicalDMAdevices:Diskdrives,tapedrivesRememberKeyboarddatarate
0.01KB/s(1byteevery100ms)Diskdrivedatarate2,000KB/s(1byteevery0.5µs)TransferrateistoohightobecontrolledbysoftwareexecutingontheCPUDirectMemoryAccess(2)DMAOperation1.TheCPU“prepares”theDMAoperationbytransferringinformationtoaDMAcontroller(DMAC):LocationofthedataonthedeviceLocationofthedatainmemorySizeoftheblocktotransferDirectionofthetransferModeoftransfer(burst,cyclestealing,transparent)2.Whenthedeviceisreadytotransferdata,theDMACtakescontrolofthesystembuses(DMAcontrollerdealswithtransfer)3.DMACsendsinterruptwhenfinishedDirectMemoryAccess(3)DMAOperation(ctd.)DatabusAddressbusControlbusMemoryDMACCPUDiskTheCPU“prepares”theDMACProgram-controlledI/ODirectMemoryAccess(4)DMAOperation(ctd.)DatabusAddressbus
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026糖尿病胰岛素注射依从性提升课件
- 2026 高血压病人饮食的外卖高血压饮食选择课件
- 地理试卷答案浙江省强基联盟2025年10月高三联考(10.8-10.10)
- 复杂主动脉腔内治疗麻醉管理2026
- 农村养老护理员护理团队建设与管理
- 七年级数学期末考试卷解析
- 2026年山东省德州市某校青岛版五年级下册期中数学检测试卷
- 长春金融高等专科学校《政治思想史》2025-2026学年期末试卷
- 厦门工学院《当代中国经济》2025-2026学年期末试卷
- 武夷学院《广播电视写作教程(彭菊华第三版)》2025-2026学年期末试卷
- 人才公寓保洁工作制度
- (2025年)重大隐患专项培训试题及答案
- (2025年)【单招真题】河南高职单招往年职业测试真题(附答案)
- 6.2 按劳分配为主体、多种分配方式并存 课件 2025-2026学年统编版 道德与法治 八年级下册
- 中石化全员绩效考核制度
- 广州市2026届高三语文一模作文示范及审题指导:古语云“父母在不远游”
- 2025年高校教师资格证之高等教育心理学考试题库(附答案)
- 2026青海省公务员真题及答案
- 2025年平顶山工业职业技术学院单招职业技能测试题库附答案解析
- 初中地理教师个人发展三年规划
- GB/T 30786-2014色漆和清漆腐蚀试验用金属板涂层划痕标记导则
评论
0/150
提交评论