📝 Interrupts in I/O Hardware (26 MCQs)
Hardware Interrupts for Event Driven I/O
An interrupt is a hardware or software signal that causes the processor to suspend its current execution flow and transfer control to an appropriate handler. In I/O systems, device controllers use interrupts to report events such as completed transfers, incoming data, or errors. This mechanism allows the processor to perform other work instead of continuously checking device status.
Why Devices Need Asynchronous CPU Notification
Peripheral operations often take much longer than individual processor instructions. Repeated polling would waste CPU cycles while a device is busy. Interrupts provide asynchronous notification, allowing the processor to continue executing other tasks until a device requires attention. Their use introduces handler overhead and requires careful coordination when several interrupt sources are active.
Interrupt Request and Handler Execution
A device raises an interrupt request through its controller or interrupt mechanism. The processor completes an appropriate execution boundary, saves the required state, and transfers control to an interrupt service routine. The handler identifies the event, acknowledges or services the device, updates request status, and arranges any deferred processing before normal execution resumes.
Example of a Completed Keyboard Input
When a user presses a key, the keyboard controller records the input and raises an interrupt. The processor temporarily transfers control to the keyboard handler, which obtains the available data and updates the input subsystem. The interrupted program can then resume, while the input becomes available to applications through normal operating system interfaces.
Responsiveness and Interrupt Handling Overhead
Interrupts improve CPU utilisation by avoiding continuous status checks and are useful for asynchronous devices. Excessive interrupt frequency can create substantial overhead, especially for high-speed data streams. Systems therefore use interrupt prioritisation, masking, coalescing, and deferred work where appropriate. Exact handling and scheduling behaviour depend on the processor architecture and operating system.
Misconceptions About Hardware Interrupts
'An interrupt immediately stops an instruction halfway through execution' is generally incorrect because processors recognise interrupts at defined execution boundaries. 'The interrupted process is permanently terminated' is false because its state can be restored. 'Every device interrupt completes all processing inside its handler' overlooks deferred processing mechanisms used by operating systems.
Exam Focus: Interrupt Sequence and CPU State
Trace the sequence from interrupt request to handler execution and return. Explain why the processor saves execution state and how the handler acknowledges a device event. Comparison questions may contrast polling with interrupts or examine interrupt priority, masking, nested interrupts, and the performance cost of frequent notifications.
Key Terms of Interrupt Handling
- Interrupt - Signal requesting processor attention.
- ISR - Routine servicing an interrupt.
- Interrupt request - Notification raised by hardware.
- Interrupt vector - Identifies an appropriate handler.
- Interrupt masking - Temporarily prevents selected interrupts.
📝 All Interrupts in I/O Hardware MCQs
Q1. What is the primary purpose of an interrupt in a computer system?
📖 Explanation: An interrupt signals the CPU to stop its current execution and run a special routine for the device that generated the signal. This enables rapid response without the CPU constantly checking the device. Options B, C, and D refer to unrelated mechanisms such as memory throughput, clock synchronization, and encryption, none of which describe the core function of an interrupt.
Q2. Which hardware component typically contains the interrupt vector table?
📖 Explanation: The interrupt vector table resides in the interrupt controller, which maps each interrupt request to the address of its service routine. The CPU fetches this address when an interrupt occurs, but it does not store the table itself. DMA controllers handle data transfers, power supplies provide electricity, and the CPU executes instructions, so those choices are incorrect.
Q3. What is the name of the hardware that prioritizes multiple interrupt requests?
📖 Explanation: The interrupt controller evaluates simultaneous interrupt requests and decides which one receives service first based on priority rules. A timer generates periodic signals, a scheduler manages task order in software, and a decoder translates binary codes, none of which perform priority arbitration for interrupts. Hence the interrupt controller is the correct answer.
Q4. Why does using interrupts generally improve CPU efficiency compared to polling?
📖 Explanation: Interrupt-driven designs allow the CPU to execute useful instructions and only switch to the service routine when the device actually needs attention, avoiding wasted cycles spent repeatedly checking device status. Polling continuously reads device registers regardless of activity, consuming time that could be used elsewhere. Options B, C, and D describe unrelated effects, making A the accurate choice.
Q5. How does an interrupt enable asynchronous communication between I/O devices and the CPU?
📖 Explanation: An interrupt lets a peripheral raise a request whenever it needs service, breaking the strict timing of the CPU’s instruction stream. The CPU can continue its current tasks until the interrupt arrives, at which point it saves state and executes the handler. Options A and D describe synchronous or polling behavior, while B misstates the role of the clock. Therefore the correct answer is C.
Q6. What is the effect of nesting interrupts on system latency?
📖 Explanation: When interrupts are nested, a higher‑priority interrupt can interrupt an already‑running lower‑priority handler, causing the lower‑priority request to wait longer before completion. This increases its effective latency. Nesting does not remove the vector table (option C) nor does it put the CPU into low power (option D). Option A is impossible because some delay always exists. Thus option B correctly describes the latency impact.
Q7. Why must interrupt service routines be short and non‑blocking?
📖 Explanation: An ISR should finish quickly to return control to the interrupted task and allow the CPU to respond to other pending interrupts. If an ISR blocks or runs for a long time, higher‑priority interrupts may be missed, and the system can deadlock if the ISR waits for resources held by the interrupted code. Options A, C, and D describe undesirable behaviors, making B the correct choice.
Q8. How does priority inversion occur in interrupt handling, and what mechanism prevents it?
📖 Explanation: Priority inversion happens when a lower‑priority task holds a resource that a higher‑priority interrupt needs, causing the high‑priority interrupt to wait. Priority inheritance temporarily raises the lower‑priority task’s priority, allowing it to finish and release the resource. Options A and B mischaracterize the inversion, and D describes a different technique. Therefore option C correctly identifies the scenario and the preventive mechanism.
Q9. What role does the end‑of‑interrupt (EOI) signal play in the interrupt controller?
📖 Explanation: The EOI signal informs the interrupt controller that the CPU has finished handling the current interrupt, allowing the controller to clear the request and make the line available for future interrupts. It does not affect the CPU clock, start new requests, or control device power, so options B, C, and D are incorrect.
Q10. Explain how vectored interrupts differ from non‑vectored interrupts in terms of address handling.
📖 Explanation: In a vectored interrupt system, the interrupting device supplies a vector that the controller maps to the exact address of its service routine, allowing the CPU to jump directly. Non‑vectored interrupts only signal the CPU that an interrupt occurred; the CPU must then read a predetermined location to find the ISR address. Options A, B, and C mix up these definitions, making D the correct description.
Q11. In a daisy‑chained bus, how does an interrupt propagate to the CPU?
📖 Explanation: A daisy‑chained bus connects devices in series, and when an interrupt occurs, the request travels along the shared lines until the CPU detects it. The CPU does not need to poll each device; instead, the interrupt signal is broadcast along the chain, and the controller determines which device originated it. Options A and B misstate the propagation method, and D describes polling, not interrupt handling. Therefore option C is correct.
Q12. When a device raises an interrupt, which sequence of actions does the CPU typically perform?
📖 Explanation: Upon receiving an interrupt, the CPU first saves the state of the currently running program, then uses the interrupt vector table to find the address of the appropriate service routine. It executes that routine and finally restores the saved state to continue the original task. Options A, C, and D describe behaviors that would either corrupt program state or cause unnecessary delays, so B is the accurate description.
Q13. If a keyboard and a network card raise interrupts simultaneously, which device is serviced first if the keyboard has higher priority?
📖 Explanation: Interrupt controllers assign priority levels to each source; when two requests occur together, the controller selects the higher‑priority one—in this case the keyboard—and forwards its vector to the CPU first. The network card’s request will be held until the keyboard’s ISR finishes. Options B, C, and D contradict the defined priority mechanism, making A the correct answer.
Q14. If a device raises an interrupt at time µs and the CPU begins executing the ISR at µs, what is the interrupt latency?
📖 Explanation: Interrupt latency is the elapsed time between the moment the interrupt is generated and the moment the CPU starts servicing it. Subtracting the raise time from the start time gives . However, the options list 25 µs as the correct choice, indicating a mis‑calculation; the correct answer should be 15 µs, which corresponds to option B. Therefore the correct answer is B.
Q15. When deciding between interrupt‑driven I/O and polling for a high‑throughput sensor, which factor most strongly favors using interrupts?
📖 Explanation: Interrupt‑driven I/O shines when the device generates data irregularly; the CPU can remain idle until the device signals that data is ready, avoiding wasted cycles. If the sensor’s rate is constant, polling may be simpler. Options A and D describe scenarios where polling or deterministic timing might be preferred, while B does not address the sensor’s behavior. Hence option C correctly identifies the advantage of interrupts.
Q16. Which hardware feature helps a real‑time operating system keep interrupt latency below 10 µs?
📖 Explanation: A dedicated interrupt controller designed for rapid arbitration can quickly identify and forward the highest‑priority request, minimizing the time the CPU spends determining which ISR to run. This directly reduces latency. While caches and multiple cores improve overall performance, they do not specifically target the interrupt‑handling path. SSD storage is unrelated to interrupt timing, making option B the appropriate choice.
Q17. In a noisy environment, which type of interrupt triggering is generally more reliable?
📖 Explanation: Level‑triggered interrupts remain active as long as the signal stays asserted, which can cause false triggers in noisy conditions. Edge‑triggered interrupts respond only to transitions, reducing susceptibility to sustained noise. However, a well‑designed edge‑triggered circuit with proper debouncing is typically more reliable than level‑triggered in such environments. Options C and D describe unrelated mechanisms. Therefore option B is the correct answer.
Q18. A timer generates an interrupt every 1 ms. After 10 seconds, how many timer interrupts have occurred?
📖 Explanation: The timer fires once every millisecond, which is . Over 10 seconds, the number of interrupts is . Thus the correct count is 10,000 interrupts, corresponding to option D. The other options represent far fewer occurrences and do not match the calculation.
Q19. Which mitigation technique is most effective against an interrupt storm that overwhelms the CPU?
📖 Explanation: An interrupt storm floods the CPU with excessive requests, causing performance collapse. Rate limiting in the interrupt controller throttles how frequently a device can generate interrupts, preventing overload while still allowing necessary signaling. Raising clock speed (A) does not address the root cause, disabling all interrupts (B) stops essential communication, and adding RAM (D) does not affect interrupt handling. Hence option C is the correct mitigation.
Q20. In systems with both hardware and software interrupts, which type typically has higher priority?
📖 Explanation: Hardware interrupts originate from external devices and are usually given higher priority because they often represent time‑critical events that the CPU must address promptly. Software interrupts are generated by programs and can be scheduled at lower priority levels. Options B, C, and D contradict typical operating‑system designs, making option A the accurate statement.
Q21. A device requires a 4‑byte aligned ISR address. Which vector entry ensures correct execution?
📖 Explanation: Alignment to a 4‑byte boundary means the address must be divisible by 4. Hexadecimal 0x1004 ends with a 4, which is a multiple of 4, satisfying the alignment requirement. Addresses 0x1003 and 0x1005 are not divisible by 4, and 0x1006, while divisible by 2, is not a multiple of 4. Therefore the correct aligned vector is 0x1004, option B.
Q22. What advantage does interrupt‑driven keyboard input have over polling?
📖 Explanation: Interrupt‑driven input lets the CPU remain in other tasks or low‑power states until the keyboard signals a key press, saving energy and processing time. While both methods can capture keystrokes, polling continuously checks the device, wasting cycles. Options B, C, and D describe unrelated benefits. Hence option A correctly identifies the primary advantage.
Q23. What is the difference between maskable and non‑maskable interrupts?
📖 Explanation: Maskable interrupts can be disabled (masked) by the CPU when it is executing critical code, allowing the system to postpone handling them. Non‑maskable interrupts (NMIs) cannot be turned off and are used for urgent events like hardware failures. Options B, C, and D mischaracterize speed, source, or priority, making option A the correct distinction.
Q24. How does the interrupt priority scheme affect real‑time guarantees in embedded systems?
📖 Explanation: In real‑time embedded designs, assigning higher priority to time‑critical interrupts guarantees they are serviced promptly, helping meet strict deadlines. Lower‑priority interrupts may be deferred, which is acceptable for non‑critical functions. Options A and B incorrectly state that priority either worsens latency or is irrelevant, and D contradicts the purpose of priority. Therefore option C accurately describes the effect.
Q25. Why is it important for an ISR to preserve the processor state?
📖 Explanation: An ISR must save registers, flags, and other context before altering them, so that when it returns, the original program continues exactly where it left off. Failing to preserve state can corrupt data, cause crashes, or produce incorrect results. Options A, B, and D describe unrelated actions that do not address the need for state preservation, making option C the correct explanation.
Q26. Explain the role of the Interrupt Descriptor Table (IDT) in modern x86 architectures.
📖 Explanation: The IDT is a data structure used by x86 CPUs to translate an interrupt vector into the linear address of its handler and to specify attributes like gate type and required privilege. It does not contain executable code itself, nor does it manage power or general memory mapping. Therefore option B correctly captures the IDT’s purpose.