Skip to main content

Interrupts vs. Polling

Interrupts vs. Polling

Polling: 

In the Polling method, the microcontroller must "access by himself" the device and “ask” for the information it needs for processing. In fact, we see that in the Polling method the external devices are not independent systems; they depend on the microcontroller, and only the micro is entitled to obtain access to the information it needs

Interrupts:

Interrupts are the signal to the microcontroller or processor to mark the event that requires immediate attention. An interrupt is “requesting" the processor to stop to perform the current program and to “make time” to execute a special code(interrupt code). Whenever any device needs its interrupt service, the device notifies the microcontroller by sending it an interrupt signal. Upon receiving an interrupt signal, the microcontroller program_counter will go to the Interrupt vector table in that it will fetch the ISR address (interrupt service routine) and it will execute the ISR program and it will return to the main program where it stopped and it will start executing the main program .

Polling uses a lot of CPU horsepower

    -checking whether the peripheral is ready or not
    -are you ready...yet?!
    -interrupts use the CPU only when work is to be done

Polled code is generally messy and unstructured

    -a big loop with often multiple calls to check and see if peripheral is ready
    -necessary to keep peripheral from waiting
    -ISRs concentrate all peripheral code in one place (encapsulation)

Polled code leads to variable latency in servicing peripherals

    -whether if branches are taken or not, timing can vary
    -interrupts give highly predictable servicing latencies


Comments

Popular posts from this blog

CAN INTERVIEW QUESTIONS

Qualifiers and Modifier in C

RTOS Real time operating system interview questions

CAN INTERVIEW QUESTIONS 2

What is UDS protocol

Memory mapping in c

TOP IOT PLATFORMS