0% found this document useful (0 votes)
441 views5 pages

Investigating IO Interrupts

This document discusses different methods of handling input/output (IO) interrupts in a computer system. It begins with an introduction to IO interrupts and interrupt vectors. It then describes two main methods of IO interrupt handling: polled interrupts and vectored interrupts. Through exercises, it demonstrates that vectored interrupts provide faster response to input compared to polled interrupts because the CPU is directly interrupted instead of continuously checking for input. While vectored interrupts are more efficient, polled interrupts may be preferred in situations where interrupt processing needs to be kept simple.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
441 views5 pages

Investigating IO Interrupts

This document discusses different methods of handling input/output (IO) interrupts in a computer system. It begins with an introduction to IO interrupts and interrupt vectors. It then describes two main methods of IO interrupt handling: polled interrupts and vectored interrupts. Through exercises, it demonstrates that vectored interrupts provide faster response to input compared to polled interrupts because the CPU is directly interrupted instead of continuously checking for input. While vectored interrupts are more efficient, polled interrupts may be preferred in situations where interrupt processing needs to be kept simple.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

InvestigatingIOInterrupts

Introduction
Attheendofthislabyoushouldbeableto:

Describewhatinterruptvectorsareandexplainhowtheyareused
DescribetwomainmethodsofIOinterrupthandling
ExplainthedifferencebetweenthetwomainmethodsofIOinterrupthandling
ComparethemeritsofthetwomainmethodsofIOinterrupthandling

BasicTheory
Computersystemsusetheinterruptmechanismasameansofrespondingto
externaleventssuchasinputandoutputoperations.TheCPUismomentarily
interruptedjustbeforeexecutingthenextinstructionandisforcedtoexecutethe
instructionsofaninterrupthandler.Oncetheinterrupthandlingiscompletedthe
CPUisreturnedbacktoexecutingtheinstructionitwasabouttoexecutebeforeit
wasinterrupted.ThestackisusedtostoretheCPUstatesuchasthecontentsof
registersandthereturnaddresswheninterrupted.Thesearethenrestoredoncethe
interrupthandlerisexited.

LabExercisesInvestigateandExplore
Thelabinvestigationsareaseriesofexercisesthataredesignedtodemonstratethe
variousaspectsofIOinterrupthandling.

Exercise1Describewhatinterruptvectorsareandexplainhowtheyareused
Inthecompilerwindow,checkonlytheboxesGeneratecode,Enableoptimizerand
RedundantCode.Enterthefollowingsourcecodeandcompileit:
program Vectors
sub IntVect1 intr 1
writeln("This is intr 1")
end sub
sub IntVect2 intr 2
writeln("This is intr 2")
end sub
sub IntVect5 intr 5
writeln("This is intr 5")
end sub
while true
wend
end
InthecompiledcodewindowlocatethesubroutinesIntVect1,IntVect2andIntVect5.
Makeanoteofthestartingaddressesofthesesubroutinesbelow:


Subroutine

Startingaddress

IntVect1

IntVect2

IntVect5

Next,dothefollowing:
1. LoadthecodegeneratedinCPUmemory.
2. ClickontheINTERRUPTSbuttontoviewtheINTERRUPTVECTORSwindow.
3. MakeanoteofthenumbersdisplayedintextboxesnexttoINT1,INT2andINT5.
Note:TheINTERRUPTVECTORSwindowinthesimulatorrepresentsthatpartofthe
CPUhardwarethatstoresthevariousinterruptroutineaddresses.

Interrupt

INT1

INT2

INT5

Comparethetwotablesaboveandenterabriefcommentonyourobservationin
thespacebelow:

Now,followtheinstructionsbelow:
1. ClickontheINPUTOUTPUTbuttontoviewtheconsolewindow.
2. SelectStayontopboxesbothintheconsoleandtheinterruptvectorswindows.
3. ResettheVectorsprogramandrunitatthefastestspeed.
4. Whiletheprogramisrunning,clickTRIGGERbuttonsintheinterruptswindow
againstINT1,INT2andINT5oneaftertheother.
5. Observethemessagesdisplayedontheconsole.Commentonyourobservations:

Tip:Ifyouruntheprogramataslowpace(speedsliderdown),youshouldbeableto
seetheeffectsofclickingontheTRIGGERbuttons.

Commentonyourobservationsinthespacebelow:

Exercise2Describetwomainmethodsofinterrupthandling
Enterthefollowingsourcecodeinanewsourceeditorandcompileit.
program PolledInt
var v integer
v = 0
writeln("Program Starting")
while true
read(nowait, v)
for i = 1 to 100
if v > 0 then
break *
end if
write(".")
next
wend
writeln("Program Ending")
end
Notes:
Thenowaitkeywordinthereadstatementmakessuretheprogramisnot
suspendedwhilewaitingforaninput.
Ifthereisnoinput,thevalueofthevariablevwillremainunchanged.
Thebreak*statementtakestheprogramoutoftheoutermostloopwhichinthis
caseisthewhileloop.
So,now,brieflyexplainwhattheaboveprogramisdoing:

Next,followtheinstructionsbelow:
1. LoadthecodegeneratedinCPUmemory.
2. Setthespeedofsimulationtomaximum.
3. Bringtheconsolewindowup(usetheINPUTOUTPUTbutton).
4. ChecktheStayontopcheckboxontheConsole.
5. ClickintheINPUTboxontheConsole.
6. StartthesimulationbyclickingtheCPUSimulatorsRUNbutton.Assoonasthe
ProgramStartingmessageisdisplayedontheConsole,typeanysinglecharacter
intheINPUTboxoftheConsole.Waituntiltheprogramterminates.

Next,enterthefollowingsourcecodeinanewsourceeditorandcompileit.
program VectoredInt
var v integer
sub InputInt intr 1
read(nowait, v)
end sub
v = 0
writeln("Program Starting")
while true
for i = 1 to 100
if v > 0 then
break *
end if
write(".")
next
wend
writeln("Program Ending")
end
Brieflyexplainwhattheaboveprogramisdoing(notewherethereadstatementisin
thiscase)

LoadthecodegeneratedinCPUmemory.Resetandrunthiscodeatthefastest
speed.AssoonastheProgramStartingmessageisdisplayedontheConsole,type
anysinglecharacterintheINPUTboxoftheConsole.Waituntiltheprogram
terminates.

Exercise3Explainthedifferencebetweenpolledandvectoredinterrupts
Basedonyourobservationinthepreviousexercise,brieflyexplainthedifferencein
thebehavioursofthetwoprograms,PolledIntandVectoredInt,with
respecttothespeedofresponsetoinput.Explainwhythisdifference.

Basedonyourobservationsinexercises2,andlookingatthetablebelow,which
interrupthandlingmethodlistedinthetable,ismoreefficient(putanXagainstit):
Interruptmethod

Selectthemost
efficientone

Polled
Interrupt

Vectored
Interrupt

Exercise4Comparethemeritsofthetwomainmethodsofinterrupthandling
1. Basedonyourobservationsabove,suggestandbrieflydescribeareason
whereyouwouldusethePolledInterruptmethodinpreferencetothe
VectoredInterruptmethod?

2. VerybrieflydescribewhereyouwouldusetheVectoredInterruptmethod
inpreferencetothePolledInterrupt?

You might also like