Describe the role and operation of interrupts

IGCSE Computer Science – Complete Syllabus Overview (Cambridge 0478)

1. Computer Systems (Syllabus Topics 1‑6)

1.1 Data Representation

  • Number systems
    • Binary, octal and hexadecimal – conversion methods (division‑remainder, multiplication, lookup tables).
    • Unsigned integers and signed integers (two’s complement). Example: 1101₂ = –3 in 4‑bit two’s complement.
    • Fixed‑point vs. floating‑point (conceptual only). Fixed‑point stores a set number of integer and fractional bits; floating‑point (IEEE 754) stores a sign, exponent and mantissa to represent a wide range of values.
  • Characters
    • ASCII – 7‑bit code (0‑127). Example: 65 → ‘A’.
    • Unicode (UTF‑8) – 8‑bit compatible encoding that can represent over a million characters. Needed for multilingual text.
  • Images
    • Bitmap (pixel matrix) – each pixel stores colour information.
    • Colour depth – number of bits per pixel (e.g., 8‑bit = 256 colours, 24‑bit = 16 million colours).
    • Resolution – width × height in pixels.
    • Vector graphics – defined by geometric primitives (lines, curves) rather than a pixel grid.
  • Sound
    • Sampling rate – how many samples per second (e.g., 44 kHz for CD quality).
    • Bit depth – number of bits per sample (e.g., 16‑bit gives 65 536 amplitude levels).
    • Mono vs. stereo – one channel vs. two channels.

1.2 Data Transmission

  • Analogue vs. digital signals – analogue varies continuously; digital uses discrete voltage levels (0/1).
  • Bandwidth, latency and throughput
    • Bandwidth – maximum data rate a link can carry (e.g., 100 Mbps).
    • Latency – time for a single bit or packet to travel from source to destination (e.g., 20 ms).
    • Throughput – actual data transferred per unit time; can be lower than bandwidth because of latency and protocol overhead.
  • Serial and parallel transmission
    • Serial – one bit at a time (e.g., RS‑232, USB).
    • Parallel – multiple bits simultaneously over separate wires (e.g., older printer ports).
  • Modulation basics (one‑sentence overview)
    • ASK – amplitude shift keying (on/off).
    • FSK – frequency shift keying (two frequencies represent 0 and 1).
    • PSK – phase shift keying (phase changes encode bits).
  • Error detection
    • Parity bit (even/odd).
    • Checksum – sum of data bytes.
    • CRC – polynomial division remainder, provides strong error detection.
  • Packet structure (simplified diagram)
    +-----------+-----------+-----------+
    |  Header   |  Payload  |  Trailer  |
    +-----------+-----------+-----------+
    | Src Addr  |   Data    |  CRC/Chk  |
    | Dest Addr |           |           |
    +-----------+-----------+-----------+
            
    The header contains addressing and control information; the payload carries the user data; the trailer holds error‑checking bits.

1.3 Computer Hardware

ComponentFunction / Key ConceptsTypical Terms
CPU (Control Unit, ALU, Registers) Fetch‑decode‑execute cycle; performs arithmetic, logic and control operations. Clock speed, instruction cycle, instruction set, registers (ACC, PC, IR)
Memory hierarchy Fast, small storage close to the CPU → slower, larger storage further away. Registers → Cache → RAM (primary) → HDD/SSD (secondary)
Buses Pathways that move data, addresses and control signals between components. Address bus (carries memory locations), Data bus (carries actual data), Control bus (carries timing and command signals)
Secondary storage Long‑term, non‑volatile data retention. HDD, SSD, magnetic tape, optical disc (CD/DVD/BD)
I/O devices Interact with the user or external systems; often use interrupts. Keyboard, mouse, scanner, printer, network card, sensor
Motherboard & bus architecture Connects CPU, memory, and peripherals; includes the system bus, expansion slots and the interrupt controller. System bus, expansion bus (PCIe), interrupt controller (PIC/APIC)

1.4 Software

  • System software – operating system, device drivers, utility programmes.
  • Application software – word processors, spreadsheets, browsers, games.
  • Programming languages
    • High‑level (Python, Java, Visual Basic) – abstracted from hardware.
    • Low‑level (assembly) – one‑to‑one with machine instructions.
  • Interrupts – see detailed Section 3.

1.5 The Internet & the World Wide Web

  • Packet‑switched networks – routers forward packets based on destination IP; switches forward within LANs using MAC addresses.
  • Addressing: MAC (hardware) vs. IP (logical) addresses.
  • Domain Name System (DNS) – translates domain names to IP addresses.
  • HTTP/HTTPS – request/response model; HTTPS adds TLS encryption.
  • Client‑server architecture and cloud computing basics – resources accessed over the network rather than locally.

1.6 Emerging Technologies

TechnologyKey FeaturesTypical Use
Digital currency (e.g., Bitcoin) Blockchain, decentralised ledger, cryptographic hashing. Online payments, investment.
Artificial Intelligence Machine learning, neural networks, natural language processing. Voice assistants, image recognition.
Robotics & automation Sensors, actuators, embedded controllers. Manufacturing, autonomous vehicles.
Internet of Things (IoT) Ubiquitous sensors, low‑power wireless communication. Smart homes, health monitoring.

2. Algorithms, Programming & Logic (Syllabus Topics 7‑10)

2.1 Algorithm Design

  • Problem decomposition – break a problem into smaller, manageable parts.
  • Control structures – sequencing, selection (if‑else), iteration (for/while).
  • Representations – flowcharts (standard symbols) and pseudocode (language‑independent).
  • Validation (checking logic) and verification (checking output against expected results).
  • Test data – normal, boundary and error‑condition cases.

2.2 Programming Concepts

ConceptDescriptionExample (Python)
Variables & data typesStore values; types include integer, float, string, Boolean.score = 85
Input / outputInteract with the user or files.name = input("Enter name: ")
Control structuresIf‑else, loops, nested structures.if score >= 50: print("Pass")
Arrays (lists)Ordered collection of same‑type items.grades = [78, 92, 85]
Functions / proceduresReusable blocks of code.def average(lst): return sum(lst)/len(lst)

2.3 File Handling

  • Opening a file – modes: r (read), w (write), a (append).
  • Reading/writing line by line or whole file.
  • Closing files to free resources.
  • Simple error handling using try/except (or equivalent).

2.4 Databases (Introductory SQL)

  • Relational model – tables (records, fields), primary key.
  • Basic commands:
    SELECT column1, column2
    FROM table_name
    WHERE condition
    ORDER BY column ASC|DESC;
  • INSERT, UPDATE, DELETE – brief syntax shown.

2.5 Boolean Logic & Logic Gates

GateSymbolTruth Table (excerpt)
AND&1 & 1 = 1; otherwise 0
OR≥10 ∨ 0 = 0; otherwise 1
NOT¬¬1 = 0, ¬0 = 1
NANDinverse of AND
NORinverse of OR
XOR1 when inputs differ

3. Software – Interrupts (Core Focus)

3.1 What Is an Interrupt?

An interrupt is a signal that temporarily suspends the normal sequential execution of a program so that the CPU can service an event that requires immediate attention. After the interrupt is serviced, the CPU restores the previous state and continues where it left off.

3.2 Why Are Interrupts Needed?

  • React to real‑time events (key press, mouse movement, sensor input) without delay.
  • Eliminate constant polling of devices, saving CPU cycles.
  • Allow many I/O devices to share a single CPU – the foundation of multitasking.
  • Provide a structured way to handle errors and exceptional conditions (e.g., division‑by‑zero, page fault).

3.3 Types of Interrupts

TypeSourceTypical Example
Hardware interruptExternal deviceKeyboard key press, timer overflow, network card signalling packet arrival.
Software interruptProgram or operating systemSystem call, arithmetic exception, breakpoint for debugging.

3.4 How an Interrupt Is Handled (Operation)

  1. Interrupt Request (IRQ) – The device asserts an IRQ line on the CPU’s interrupt controller.
  2. CPU Acknowledgement – After completing the current instruction, the CPU checks the interrupt flag.
  3. Interrupt Vector Lookup – The IRQ number indexes the interrupt vector table to obtain the address of the corresponding Interrupt Service Routine (ISR).
  4. Save Context – The CPU pushes the current Program Counter (PC) and status registers onto the stack (or into dedicated registers).
  5. Execute ISR – Control jumps to the ISR, which performs the required service (e.g., reads a byte from a keyboard buffer, acknowledges a timer tick).
  6. Clear / Acknowledge Interrupt – The ISR signals the interrupt controller that the request has been handled, allowing lower‑priority interrupts to be recognised.
  7. Restore Context – The saved PC and registers are popped, returning the CPU to the point of interruption.
  8. Resume Program – Execution continues with the instruction that was interrupted.

3.5 Interrupt Priorities and Masking

  • Each IRQ is assigned a priority level; the CPU always services the highest‑priority pending interrupt first.
  • While an ISR runs, lower‑priority interrupts can be masked (temporarily disabled) to prevent unwanted nesting.
  • Some CPUs support nested interrupts where a higher‑priority interrupt can pre‑empt a lower‑priority ISR.

3.6 Everyday Examples of Interrupts

  • Keyboard & mouse – each key press or mouse movement generates a hardware interrupt.
  • Timer interrupts – used by operating systems to implement time‑slicing for multitasking and to update system clocks.
  • Network cards – raise an interrupt when a data packet is received or when the transmit buffer becomes free.
  • System calls – software interrupts that allow user programmes to request OS services such as file I/O.
  • Exception handling – division‑by‑zero, illegal memory access, or overflow trigger a software interrupt that invokes an error‑handling routine.

3.7 Diagram – Interrupt Flow (textual representation)

IRQ asserted → CPU finishes current instruction
        ↓
CPU checks interrupt flag
        ↓
Vector table lookup (IRQ → ISR address)
        ↓
Save PC & status registers (stack)
        ↓
Jump to ISR → service the event
        ↓
Acknowledge / clear interrupt in controller
        ↓
Restore PC & registers
        ↓
Resume interrupted program

3.8 Key Points to Remember

  • Interrupts provide rapid response without the overhead of continuous polling.
  • Every interrupt has a unique vector that points to its ISR.
  • The CPU must save the current state (PC, registers) before servicing and restore it afterwards.
  • Priorities and masking ensure that critical events are handled before less important ones.
  • Both hardware and software interrupts are essential for modern multitasking operating systems.

4. Assessment Objectives (AO1‑AO3) Mapping

AOWhat It AssessesRelevant Content
AO1Recall of factual knowledge.Definitions of binary, hex, two’s complement, Unicode, colour depth, bandwidth, latency, interrupt, vector table, priority.
AO2Application of knowledge to solve problems.Convert numbers, design flowcharts for ISRs, write pseudocode for interrupt‑driven programmes, construct simple SQL queries, calculate throughput.
AO3Evaluation and justification.Discuss advantages of interrupts vs. polling, evaluate impact of an emerging technology, compare primary vs. secondary storage, assess trade‑offs of different error‑detection methods.

5. Practical Worksheet – Applying the Concepts

  1. Scenario: A microcontroller must read a temperature sensor every 2 seconds and, whenever a user presses a button, store the current temperature in a log file.
  2. Task A – Pseudocode
    Initialize timer (2 s interval)
    Initialize button interrupt
    Loop forever
        Wait for next timer interrupt
        Read temperature sensor → temp
    End Loop
    
    ISR_ButtonPress:
        Open log file (append)
        Write temp and timestamp
        Close file
        Clear button interrupt flag
            
  3. Task B – Flowchart – Convert the above pseudocode into a flowchart using standard symbols (start, process, decision, input/output, connector).
  4. Task C – Code Snippet (optional)
    // Arduino example
    volatile float latestTemp = 0.0;
    
    void setup() {
        Serial.begin(9600);
        pinMode(2, INPUT_PULLUP);          // button on pin 2
        attachInterrupt(digitalPinToInterrupt(2), buttonISR, FALLING);
        Timer1.initialize(2000000);        // 2 s
        Timer1.attachInterrupt(timerISR);
    }
    
    void loop() {
        // main loop does nothing – all work done in ISRs
    }
    
    void timerISR() {
        latestTemp = readTemperature();    // user‑defined function
    }
    
    void buttonISR() {
        File log = SD.open("temp.txt", FILE_WRITE);
        log.println(latestTemp);
        log.close();
    }
            
  5. Task D – Evaluation – Explain why an interrupt‑driven solution is preferable to a polling solution for the button (e.g., lower CPU utilisation, immediate response, power saving).

6. Sample Exam‑Style Questions

  1. Explain how a timer interrupt can be used by an operating system to implement multitasking. (AO2)
  2. Convert the binary number 10110110₂ to hexadecimal and decimal. (AO1)
  3. Write a short SQL query to retrieve the names of all students who scored more than 80 in Mathematics, ordered alphabetically. (AO2)
  4. Discuss two advantages and two disadvantages of using cloud storage for personal data. (AO3)
  5. Given the flowchart fragment below, describe what the program does and identify any potential errors. (AO2)

Create an account or Login to take a Quiz

45 views
0 improvement suggestions

Log in to suggest improvements to this note.