COMPUTER SCIENCE CAFÉ
  • WORKBOOKS
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • BLOCKY GAMES
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
  • WORKBOOKS
  • GCSE
    • CAMBRIDGE GCSE
  • IB
  • A LEVEL
  • LEARN TO CODE
  • ROBOTICS ENGINEERING
  • MORE
    • CLASS PROJECTS
    • BLOCKY GAMES
    • Classroom Discussions
    • Useful Links
    • SUBSCRIBE
    • ABOUT US
    • CONTACT US
    • PRIVACY POLICY
HOME    >    IB    >    COMPUTER FUNDAMENTALS
NEXT PAGE >
INTERUPT HANDLING
Picture

COMPUTER FUNDAMENTALS | INTERRUPT HANDLING

DESIGNED FOR IB EXAMINATIONS
OBJECTIVES
A1.3.4 Evaluate the use of polling and interrupt handling.
• Event frequency, CPU processing overheads, power source (battery or mains), event predictability,  controlled latency, security concerns
• Real-world scenarios may include keyboard and mouse inputs, network communications, disk input/ output operations, embedded systems, real-time systems.
  • LEARN
  • TERMINOLOGY
  • QUESTIONS
  • FLASHCARDS
  • WORKBOOK
<
>

SECTION 1 | INTERRUPT HANDLING

When designing an operating system or embedded system, engineers must decide whether polling or interrupt handling is the more appropriate method for responding to events. This decision depends on several key factors related to performance, efficiency, predictability, and security.

Event Frequency
Event frequency refers to how often an event occurs.
  • Polling is more suitable when events occur very frequently or at regular intervals. Continuously checking for an event may be acceptable if the event is almost always present.
  • Interrupt handling is more efficient when events occur infrequently or unpredictably, as the CPU is only notified when the event actually happens.

​CPU Processing Overheads

Polling requires the CPU to repeatedly check the status of a device or condition, even when no event has occurred. This can lead to:
  • Wasted CPU cycles
  • Reduced overall system efficiency
Interrupt handling reduces CPU overhead because the CPU can perform other tasks and only pauses execution when an interrupt signal is received. However, handling interrupts still incurs overhead due to context switching and interrupt servicing.

Power Source (Battery or Mains)
Power availability is a critical consideration:
  • Polling consumes more power because the CPU remains active, repeatedly checking for events.
  • Interrupt-driven systems are more energy-efficient, as the CPU can enter low-power or sleep states and wake only when an interrupt occurs.
As a result, interrupt handling is preferred in battery-powered devices, while polling may be acceptable in systems connected to a constant mains power supply.

Event Predictability
If events occur at known and predictable times:
  • Polling can be scheduled efficiently, reducing unnecessary checks.
If events are unpredictable:
  • Interrupt handling is more effective because the system reacts immediately when the event occurs, regardless of timing.

Controlled Latency
Latency is the delay between an event occurring and the system responding to it.
  • Polling introduces variable latency depending on how often the system checks for events.
  • Interrupts provide controlled and often lower latency, as the CPU responds immediately to the interrupt signal.
This makes interrupt handling especially important in real-time systems, where delayed responses can cause system failure.

Security Concerns
Both approaches have security implications:
  • Polling systems may expose predictable behaviour patterns, which could be exploited if an attacker can anticipate checks.
  • Interrupt handling can be vulnerable if interrupts are generated excessively or maliciously, potentially leading to denial-of-service conditions.
Operating systems must therefore validate interrupt sources and manage priorities carefully to maintain system security.

Choosing between polling and interrupt handling requires balancing efficiency, responsiveness, power usage, predictability, and security. No single approach is universally better; instead, the optimal choice depends on system requirements and operating conditions.

Why is interrupt handling often preferred in battery-powered systems?

A. It makes events easier to predict.
B. It always produces lower latency than polling.
C. It allows the CPU to sleep, reducing power consumption.
D. It prevents all security risks.

SECTION 2 | REAL WORLD SCENARIOS

Polling and interrupt handling are used in different ways depending on the type of system and the nature of the events being handled. Real-world scenarios help illustrate why one approach may be preferred over the other.

Keyboard and Mouse Inputs
Keyboard and mouse events occur unpredictably and require fast response times to maintain a smooth user experience.
  • Interrupt handling is commonly used because the CPU is notified immediately when a key is pressed or the mouse is moved.
  • Polling would waste CPU time checking for input when no interaction is occurring and could introduce noticeable delays.

Network Communications
Network data arrives at unpredictable times and may require immediate processing.
  • Interrupt-driven I/O allows the operating system to respond as soon as data packets arrive.
  • Polling could lead to inefficient CPU usage, especially during periods of low network activity.
Interrupts also support prioritization, allowing critical network traffic to be handled promptly.

Disk Input/Output Operations
Disk operations often take much longer than CPU operations.
  • The operating system typically uses interrupts to signal when a disk read or write operation has completed.
  • This allows the CPU to perform other tasks instead of repeatedly checking whether the operation has finished.
Polling would significantly increase CPU overhead during disk operations.

Embedded Systems
Embedded systems are designed for specific tasks and often have limited processing power and energy resources.
  • Interrupt handling is widely used to respond to sensors, timers, or external signals efficiently.
  • Polling may be used in very simple embedded systems where events are predictable and system complexity must be minimized.

Real-Time Systems
Real-time systems must respond to events within strict time limits.
  • Interrupts provide controlled and predictable response times, making them essential in real-time environments such as medical devices or industrial control systems.
  • Polling can be used when timing is highly predictable, but it risks missing deadlines if the polling interval is poorly chosen.

In practice, operating systems often combine polling and interrupt handling. Interrupts are favored for unpredictable or infrequent events, while polling may be used for simple, predictable tasks. The choice depends on responsiveness, efficiency, and system requirements.

Which scenario is most appropriate for interrupt handling?

A. Checking a sensor at fixed, predictable intervals.
B. Detecting when a user presses a key on a keyboard.
C. Repeatedly checking whether a timer has expired.
D. Handling events that occur continuously and predictably.
Polling | A technique where the CPU repeatedly checks the status of a device or condition to see if an event has occurred.
Interrupt | A signal sent to the CPU by hardware or software to indicate that an event requires immediate attention.
Interrupt Handling | The process by which the operating system pauses the current task and executes an interrupt service routine.
Interrupt Service Routine (ISR) | A special routine executed by the CPU in response to an interrupt.
Event | An occurrence that requires a response from the operating system, such as input from a device or completion of an operation.
Event Frequency | How often an event occurs over a period of time.
CPU Processing Overhead | The extra CPU time and resources required to manage tasks such as polling, interrupts, or context switching.
Latency | The delay between an event occurring and the system responding to it.
Controlled Latency | Predictable and bounded response time to events, often required in real-time systems.
Power Consumption | The amount of electrical energy used by a system, influenced by CPU activity and event-handling methods.
Battery-Powered System | A system that relies on a limited power source, making energy-efficient techniques such as interrupts important.
Mains-Powered System | A system connected to a continuous power supply, where energy efficiency may be less critical.
Event Predictability | How regular and foreseeable the timing of events is.
Security Concerns | Risks related to misuse or exploitation of polling or interrupts, such as interrupt flooding or predictable behavior patterns.
Interrupt Flooding | A situation where excessive interrupts overwhelm the CPU, potentially causing denial of service.
Real-Time System | A system that must respond to events within strict time constraints.
Embedded System | A specialized computer system designed to perform a specific task, often using polling or interrupts to handle events.
Input/Output (I/O) | Communication between the computer system and external devices such as keyboards, disks, or network interfaces.
Context Switching | Saving the state of a running process and restoring another so the CPU can switch tasks.
Picture
Open-Ended Questions – Polling and Interrupt Handling
  1. Explain what polling is and describe how it differs from interrupt handling.
  2. Discuss how event frequency influences the choice between polling and interrupt handling.
  3. Explain why polling can lead to higher CPU processing overhead compared to interrupt handling.
  4. Describe how the system’s power source (battery-powered vs mains-powered) affects the choice of event-handling method.
  5. Explain the concept of event predictability and how it relates to polling and interrupts.
  6. Discuss what is meant by controlled latency and why it is important in some systems.
  7. Explain how interrupt handling can improve responsiveness compared to polling.
  8. Describe potential security concerns associated with interrupt handling.
  9. Explain why interrupt handling is commonly used for keyboard and mouse input.
  10. Compare the use of polling and interrupts in real-time or embedded systems, giving reasons for when each approach may be suitable.

Sample Answers

1) Explain what polling is and describe how it differs from interrupt handling.

Polling is when the CPU repeatedly checks a device/condition to see if an event has occurred. Interrupt handling differs because the device signals the CPU when an event occurs, so the CPU does not need to keep checking.

2) Discuss how event frequency influences the choice between polling and interrupt handling.

If events are frequent or continuous, polling may be acceptable because checks are likely to find an event. If events are infrequent, interrupts are usually better because polling would waste CPU time checking when nothing happens.

3) Explain why polling can lead to higher CPU processing overhead compared to interrupt handling.

Polling consumes CPU cycles repeatedly checking status even when no event occurs, reducing efficiency. Interrupts avoid unnecessary checks, although they still have overhead from context switching and running the ISR.

4) Describe how the system’s power source (battery-powered vs mains-powered) affects the choice of event-handling method.

Battery-powered systems benefit from interrupts because the CPU can sleep and wake only when needed, saving energy. Polling keeps the CPU active and uses more power, which is less suitable for battery devices but may be acceptable on mains power.

5) Explain the concept of event predictability and how it relates to polling and interrupts.

Predictability refers to whether events occur at known times/intervals. If predictable, polling can be scheduled to check at the right moments. If unpredictable, interrupts are preferable because the system is notified immediately when the event happens.

6) Discuss what is meant by controlled latency and why it is important in some systems.

Controlled latency means the response time to an event is predictable and bounded. This is important in real-time systems where late responses can cause failures (e.g., industrial control or medical devices).

7) Explain how interrupt handling can improve responsiveness compared to polling.

Interrupts allow the CPU to respond as soon as an event occurs, rather than waiting until the next poll. This typically reduces delay and improves responsiveness, especially when polling intervals are long.

8) Describe potential security concerns associated with interrupt handling.

If an attacker can trigger excessive interrupts (interrupt flooding), the CPU may be overwhelmed, causing denial of service. Systems must validate interrupt sources, manage priorities, and limit how interrupts are handled.

9) Explain why interrupt handling is commonly used for keyboard and mouse input.

Keyboard and mouse events are unpredictable and users expect immediate feedback. Interrupts notify the CPU instantly when input occurs, avoiding wasted CPU time and reducing noticeable delay.

10) Compare the use of polling and interrupts in real-time or embedded systems, giving reasons for when each approach may be suitable.

Interrupts are often used for efficiency and fast, bounded response to events (important in real-time systems). Polling can be suitable in simple embedded systems with predictable timing or when system design must be minimal, but it can waste CPU time and power and may risk missing deadlines if the poll rate is wrong.

COMING SOON
Picture
A1.1 COMPUTER HARDWARE AND OPERATION
    ☐  1.1.1 FUNCTIONS OF THE CPU
    ☐ 1.1.2 ROLE OF THE GPU
    ☐ 1.1.3 CPU VS GPU
    ☐ 1.1.4 PURPOSE AND TYPES OF PRIMARY MEMORY
    ☐ 1.1.5 FETCH, DECODE AND EXECUTE CYCLE
    ☐ 1.1.6 PIPELINING IN MULTICORE ARCHITECTURES
    ☐ 1.1.7 SECONDARY MEMORY STORAGE
    ☐ 1.1.8 CONCEPTS OF DATA COMPRESSION
    ☐ 1.1.9 CLOUD COMPUTING

A1.2 DATA REPRESENTATION AND COMPUTER LOGIC
    ☐  1.2.1 REPRESENTING DATA
    ☐ 1.2.2 HOW BINARY IS USED TO STORE DATA
    ☐ 1.2.3 LOGIC GATES
    ☐ 1.2.4 TRUTH TABLES, CIRCUITS, EXPRESSIONS AND K MAPS
    ☐  1.2.5 LOGIC CIRCUIT DIAGRAMS - COMING SOON

A1.3 OPERATING SYSTEMS AND CONTROL SYSTEMS
    ☐  1.3.1 ROLE OF OPERATING SYSTEMS
    ☐ 1.3.2 FUNCTIONS OF OPERATING SYSTEMS
    ☐ 1.3.3 APPROACHES TO SCHEDULING
    ➩ 1.3.4 INTERUPT HANDLING
    ☐ 1.3.5 MULTITASKING
    ☐ 1.3.6 CONTROL SYSTEM COMPONENTS
    ☐ 1.3.7 CONTROL SYSTEM APPLICATIONS
Picture
SUGGESTIONS
We would love to hear from you
SUBSCRIBE 
To enjoy more benefits
We hope you find this site useful. If you notice any errors or would like to contribute material then please contact us.