At certain times, the main processor stops working and checks if some controller has a message for it, if it has, processes the message and resumes operation. This is called polling. Furthermore, it is clear that the main processor does its job, and the devices are doing their job. If the device finishes its job or an error occurs, the device informs the main processor with an interrupt request.
What is Polling?
In systems where more external logic circuits communicate through multiple U/I interconnections with a single microprocessor, U/I polling is used. The microcomputer periodically calls each external logic circuit and examines whether it has requested service. If the external logic circuit does not require servicing, the microcomputer examines the next external logic circuit, etc. If one of them requires servicing, the microcomputer switches to running the serving program of the respective external logic circuitry. The U/I transfer function is included in the program. In other words, polling is a process of client calling (computers or terminals) that can send data after being called (if they have any). If the client has data he sends it after the poll, and if there is no data the client responds negatively, and the server calls the next client. Some devices may require servicing from the controller (e.g. when some device finishes the measurement or when an error occurs). The request is sent to the controller by setting the SRQ line to low. After the controller receives a request for service, then he calls all the devices on the bus to find the device that sent that request.
What is Interrupt?
During the execution of a program, the microprocessor can receive interruption signal through the special IRQ lines. Interruption is most commonly performed by calling the appropriate system subroutine for interrupt processing – these are so called BIOS or DOS interruption routine processing. After interrupt processing, the processor continues to execute the interrupted program. Also, the application program itself may contain an instruction that calls for execution of a BIOS or DOS interrupt routine. Input-output operations are most commonly accomplished in this way. For example, if a program wants to print a sign on the screen, it can do so by calling the appropriate interrupt routine. The BIOS contains a set of elementary input-output routines that run relatively quickly, and the corresponding DOS routines are slower but their capabilities are larger (the possibility of overriding the input-output channels, the possibility of controlling errors and such). Therefore, hardware interrupt is the signal received by the processor from another device in the computer, and software interrupt is the execution process of a BIOS or DOS routine (subroutine) that is automatically called for processing the received interrupt signal or is called upon to execute the corresponding instructions.
Difference Between Polling and Interrupt
Background of Polling and Interrupt
In the first case, the processor checks at regular time intervals if a device needs an action. In case of an interrupt there is a mechanism by which the processor allows the external device (e.g. keyboard, sound card, etc.) to attract the processor’s attention.
Mechanism of Polling and Interrupt
Interrupts are specially organized mechanisms for communication of peripheral devices. The devices notify the CPU if an action is needed. Polling is protocol – the CPU asks the devices regularly if an action is required.
Servicing of Polling and Interrupt
In polling the microcontroller services the device needing attention, and after that moves to the next device for monitoring. In case of interruption, when a signal for interruption is received, the CPU stops with the current activity and services the device. The services or the interruption processed is named interrupt service routine (ISR) or interrupt handler.
CPU
In the polling process, the CPU is on hold and checks if any device needs a service. This unnecessarily wastes time. In case of interruption process, on the other hand, the CPU is disturbed only if needed.
Appearance of Polling and Interrupt
The devices can be polled only at the regular interval when they are checked. Interruption can happen in any given time.
Advantages of Polling and Interrupt
Some of the advantages of polling are the relatively simple program, transmission reliability that takes place at maximum speed, i.e. as soon as the I/O device is ready and the no need of additional access chips. Interruption is beneficial because it can serves multiple devices, it is more flexible and efficient.
Disadvantages of Polling and Interrupt
Disadvantages of polling are the standby time of some devices that is shorter than the response time and then another method of transmission should be applied, as well as that the CPU consumes unnecessary time to check devices that have not searched for data transfer. Disadvantages of interrupts are the requirement for more complex hardware/software and loss of time until the CPU establishes which units request for interruption.
Polling vs. Interrupt: Comparison Chart
Summary of Polling Vs. Interrupt
- In case of polling a cyclic reading of devices connected to one CPU is done. If the external logic circuit does not require servicing, the microcomputer examines the next external logic circuit. If one of them requires servicing, the microcomputer switches to running a program to serve the respective external logic circuit.
- When interrupted, at the request of external logic, the microcomputer interrupts the running of its current program and switches to running the interrupt program. The interrupted structure allows the microprocessor to respond to the asynchronous events, i.e. requests from external logic, not to wait in the loop to examine the state of the external logic circuit.