Originally posted by suityou01
View Post

Polling means the code occasionally has a look to see if a condition has occurred and, if so, does something about it.
An interrupt involves the hardware, upon entering a certain state, sending a signal to the processor which causes it to stop whatever code it might happen to be executing at that instant, save its state, and go off and execute a special chunk of code designated for that purpose, called the interrupt handler. Once it returns from the interrupt handler, the processor restores its state, and goes back to whatever it was in the middle of when interrupted.
In pseudocode: polling is like
Code:
.main
doSomething
doSomethingElse
if thingHasHappened:
doSpecialThing # always happens here, implying known state after things done
goto .main
Code:
.interruptHandler
doSpecialThing
returnFromInterrupt
.main
doSomething # interrupt could happen here
doSomethingElse # or here
doThirdThing # or here
doFourthThing # anywhere, really - state could be anything
goto .main



Leave a comment: