Canonical Device (Concept)- Polling and Programmed I/O (PIO)
1. Canonical Device (Concept)
🔷 What is a Canonical Device?
A canonical device is a simplified model (abstraction) used to understand how the OS interacts with hardware.
👉 It is not a real device, but a teaching model.
🔷 Two Main Parts
1. Device Interface (Visible to OS)
This is how the OS communicates with the device using registers:
-
Status Register → tells if device is busy/ready/error
-
Command Register → tells device what to do
-
Data Register → sends/receives data
📌 Key idea:
👉 OS controls the device only through this interface
2. Device Internals (Hidden from OS)
This is implementation-specific and may include:
-
Microcontroller (mini CPU)
-
Memory (SRAM/DRAM)
-
Firmware (embedded software)
-
Device-specific logic
📌 Example:
-
RAID controller = complex internal system with firmware
🎯 Key Insight
👉 The OS interacts with devices through a standard interface, ignoring internal complexity
🔄 2. Canonical Protocol (Device Interaction)
This defines how the OS communicates step-by-step with a device. The protocol is follows
While (STATUS == BUSY); // wait until device is not busy
Write data to DATA register
Write command to COMMAND register
(Doing so starts the device and executes the command)
While (STATUS == BUSY)
; // wait until device is done with your request
🔷 Steps in the Protocol
Step 1: Wait until device is ready ( Polling)
Step 2: Send data
Step 3: Issue command
Step 4: Wait for completion ( Polling)
🔁 3. Polling (Core Concept)
🔷 What is Polling?
👉 Polling = repeatedly checking the device status register
-
OS keeps asking:
“Are you done? Are you ready?”
🔷 Where Polling Occurs
-
Before sending command → check readiness
-
After issuing command → check completion
🔷 Why It’s Used
-
Simple to implement
-
Works for all devices
Problems with Polling
🔴 1. CPU Wastage
-
CPU sits in a loop doing nothing useful
-
Cannot execute other processes
🔴 2. Inefficient for Slow Devices
-
Disk, network, etc. are slow
-
CPU is much faster → huge idle time
🔴 3. Poor System Performance
-
Reduces multitasking efficiency
🔄 4. Programmed I/O (PIO)
🔷 What is PIO?
👉 When CPU itself moves data to/from device
-
Data written via DATA register
-
CPU actively involved in transfer
🔴 Limitation
-
High CPU overhead for large data transfers
5. Teaching Analogy
👉 Think of polling like:
-
A student repeatedly asking:
“Sir, is my paper corrected?”
Instead of:
-
Teacher informing when done (interrupt)
6. Key Takeaways
-
Canonical device = abstraction with:
-
Interface (registers)
-
Internals (hidden)
-
-
Polling:
-
Continuous checking of status register
-
Simple but inefficient
-
-
Protocol:
-
Wait (poll)
-
Send data
-
Issue command
-
Wait again (poll)
-
-
Main drawback:
👉 Wastes CPU time → motivates interrupts and DMA

Comments
Post a Comment