I/O, Interrupts, and Device Drivers Flashcards
(20 cards)
I/O overview
Look at I/O mechanisms
– How we implement and control access to devices
– Clocks and Timers
* Used to control and synchronise operations
Memory Mapped I/O
I/O devices visible as memory addresses
– Easily accessed using C point
Isolated I/O
Separate bus for I/O devices
– Easier interfacing: distinct from high-speed memory bus
– Accessed via special instructions
* Generally not supported by compilers (must use assembler)
Optimising Memory Use
Buffers used to smooth I/O operations.
Input/Output buffers allow CPU and devices to work asynchronously.
Status registers track readiness and availability.
Direct Memory Access
- Alternative to programmed I/O
- Relieves CPU of data transfer (improving speed and reducing load)
Clocks & Timers
RTC (Real-Time Clock): Tracks real-world date/time.
PIT (Programmable Interrupt Timer): Generates regular interrupts for periodic tasks
Efficient Timer Use
Instead of constant intervals, set timers to fire when the next task is due.
Saves CPU time, improves responsiveness.
Used in OS scheduling and simulation systems.
What is an Interrupt?
A signal to the CPU that an event needs attention.
Temporarily halts the current process, handles the event, then resumes.
Types of Interrupts
Hardware
Triggered by I/O devices (e.g., keyboard, disk)
Software
Triggered by programs (e.g., divide by zero)
Timer
From a system clock (e.g., every 10ms)
System Calls
Controlled interrupts to switch to kernel mode
Why Interrupts Matter
Efficient I/O: Devices notify CPU when ready.
Multitasking: Timer interrupts help switch processes.
Responsiveness: Quick reaction to user input or errors.
Maskable vs Non-Maskable
Maskable: Can be disabled (e.g., during critical sections).
Non-Maskable: Always handled (e.g., serious hardware failures).
Context Switching
Caused by timer or I/O interrupt.
CPU saves current process and loads another (for multitasking)
Polling
CPU repeatedly checks (polls) each device to see if it needs attention.
cons: Inefficient – wastes CPU time checking idle devices.
pros:
No need for interrupts
Nested Interrupts
A higher-priority interrupt can interrupt a currently running ISR (Interrupt Service Routine).
cons: More complex to manage.
pros:
Improves system responsiveness to critical tasks.
Device drivers
Extensible model
– Create new drivers as needed to control hardware/ devices
– Dynamically loadable modules allow run-time c
Unix Device Driver Interface
Unified, file-like interface using standard functions:
open(), read(), write(), ioctl(), mmap(), close(),
Device Driver Table
Maintains function pointers for each supported operation.
Devices may leave unsupported operations as null or error.
Tasks Performed by Drivers
I/O scheduling (e.g. reordering disk operations).
Buffering, spooling, caching.
Error handling.
I/O protection (prevent unauthorized access).
Single vs Multi-instance Devices
Single-instance: Only one process can use the device at a time (e.g. printer); use spooling.
Multi-instance: Can serve many processes concurrently (e.g. keyboard input).
Unix I/O System Architecture
Treats everything as a file: plain files, devices, sockets.
Uses cooked (processed) and raw (direct) modes:
Cooked: e.g. line-based input editing.
Raw: e.g. direct disk block access including metadata.