🧠 What is a Device Queue?

A Device Queue holds all the processes that are waiting for a specific I/O device to become available or complete an operation.

While the Ready Queue is for CPU time, the Device Queue is for hardware I/O like:

  • Disk

  • Network

  • Printer

  • USB

  • GPU


🧩 Why Is It Needed?

I/O devices are much slower than CPUs, and can usually handle only one request at a time.
If multiple processes request access, they’re placed in a queue managed by the OS I/O subsystem.


📦 Key Features of Device Queues

FeatureDescription
🔌 Device-SpecificEach I/O device has its own separate queue
💤 Blocked StateAll processes here are in Blocked or Waiting state
⏱️ Triggered by EventsWhen I/O completes, the OS moves the process to the Ready Queue
🧠 Managed byI/O Scheduler (part of OS), not the CPU scheduler

🔁 Lifecycle of a Process in a Device Queue

  1. Process requests I/O (e.g., file read).

  2. OS initiates the request.

  3. Process moves to Blocked state and enters the Device Queue.

  4. When I/O completes, an interrupt is raised.

  5. OS moves process from Device Queue → Ready Queue.

  6. Eventually, CPU scheduler picks it again.


🧪 Example

read(fd, buffer, size);  // Blocking call
  • While the disk is reading, the process is moved to the Disk I/O Queue.

  • Another process gets to run on the CPU in the meantime.


🖼️ Diagram

               CPU
                ↑
                |
       +--------+--------+
       | Ready Queue     |
       +--------+--------+
                |
        +-------+---------+
        ↓                 ↓
[ Disk Queue ]     [ Network Queue ]
     ↓                    ↓
+-------------+    +-------------+
| P1 waiting  |    | P3 waiting  |
+-------------+    +-------------+

→ Once I/O completes → move back to Ready Queue

⚙️ Real-World Analogy

Imagine a bank where multiple people want to use the ATM (I/O device).
Only one person can use it at a time.
Others wait in a queue (Device Queue) until it’s free.


🧠 Interview-Ready Definition:

A Device Queue is a queue maintained by the OS for each I/O device, containing processes that are waiting for I/O operations to complete. These processes are in a Blocked state and are moved back to the Ready Queue when the I/O event finishes.