Course Content
Bonus Section (for Interviews and GATE/Placement prep)
0/2
Operating Systems (OS)
Polling vs Interrupts vs DMA

When a computer system communicates with external devices such as a printer, disk, or keyboard, it must decide how to transfer data and manage the interaction. There are three fundamental techniques used by operating systems to coordinate this communication: Polling, Interrupts, and Direct Memory Access (DMA). Each method differs in how the CPU is involved and how efficiently data moves between the I/O devices and memory.

 

Understanding these techniques is critical to evaluating system performance, responsiveness, and overall efficiency in handling input/output operations.


Polling

Polling is a technique where the CPU continuously checks the status of an I/O device at regular intervals to determine if it’s ready for communication or has completed a task.

How it works:

 

  • The CPU issues a command to the device.
  • It then repeatedly checks (polls) the device’s status register.
  • Once the device is ready, the CPU proceeds with data transfer.

 

Pros:

 

  • Simple to implement.
  • Gives CPU complete control over the timing of operations.

 

Cons:

  • CPU time is wasted during idle waiting.
  • Not suitable for high-speed or high-frequency I/O tasks.

 

Example Use Case: Suitable for devices with infrequent communication needs, such as reading from a keyboard in low-power embedded systems.


Interrupts

Interrupts provide a more efficient alternative to polling. Instead of constantly checking the device, the CPU can continue executing other tasks. When the I/O device is ready, it sends an interrupt signal to the CPU.

How it works:

 

  • The device sends an interrupt signal when it needs attention.
  • The CPU pauses its current task, handles the interrupt through an interrupt service routine (ISR), and then resumes the paused task.

 

Pros:

 

  • Saves CPU resources by allowing multitasking.
  • Faster response to device readiness compared to polling.

 

Cons:

 

  • Requires additional hardware and software support.
  • Frequent interrupts can still affect CPU performance (interrupt overhead).

 

Example Use Case: Ideal for keyboards, network cards, and real-time systems where timely response is important.


Direct Memory Access (DMA)

DMA is a technique that allows the I/O device to transfer data directly to or from memory without involving the CPU for each byte of data.

How it works:

 

  • The CPU sets up the DMA controller with the memory address, the size of the data, and the direction of transfer.
  • The DMA controller manages the data transfer directly between memory and the device.
  • Once the transfer is complete, the controller notifies the CPU via an interrupt.

 

Pros:

 

  • Frees up the CPU to perform other tasks.
  • High-speed data transfer with minimal CPU involvement.
  • Ideal for large volumes of data.

 

Cons:

 

  • Requires dedicated DMA hardware.
  • Adds system complexity.

 

Example Use Case: Used in high-speed operations such as reading/writing to hard drives, streaming audio/video, and network communication.

0% Complete
WhatsApp Icon

Hi Instagram Fam!
Get a FREE Cheat Sheet on System Design.

Hi LinkedIn Fam!
Get a FREE Cheat Sheet on System Design

Loved Our YouTube Videos? Get a FREE Cheat Sheet on System Design.