Scheduling Queues
Scheduling queues are the data structures an operating system uses to track processes at each stage of their lifecycle. The job queue holds every process in the system, the ready queue holds processes in memory waiting for the CPU, and a device queue for each I/O device holds processes waiting on that device.
As processes move through their lifecycle, the operating system tracks them using several distinct queues, each representing a different state a process can be waiting in. Understanding these queues is really understanding the concrete data structures behind the abstract idea of process scheduling.
The main queues
Job queue. Holds every process that exists in the system, whether it's currently in memory or not. This is the broadest queue, used by the long-term scheduler to decide admission.
Ready queue. Holds every process that is currently in memory and ready to run, just waiting for the CPU. This is the queue the short-term (CPU) scheduler picks from on every scheduling decision.
Device queues (one per I/O device). Holds every process currently waiting for a specific I/O device (a disk, a network interface, a printer) to become available or to finish an operation it requested.
How a process moves between these queues
A process's typical journey: it starts in the job queue when created. Once admitted, it moves to the ready queue. When the scheduler picks it, it runs on the CPU. If it needs to perform I/O (reading a file, waiting on network data), it moves out of the CPU and into the appropriate device queue, waiting for that operation to complete. Once the I/O finishes, it moves back into the ready queue, waiting for the CPU again. This cycle, ready queue to CPU to device queue to ready queue, repeats until the process finishes entirely.
A worked example
A process needs to read a large file, then do some computation, then write results back to disk. It enters the ready queue, gets scheduled, starts running, immediately issues a read request, and moves into the disk's device queue while the actual disk I/O happens. Once the read completes, it moves back into the ready queue. It eventually gets scheduled again, runs its computation on the CPU, then issues a write request, moving into the disk's device queue a second time. Once that write completes, it returns to the ready queue one final time, gets scheduled, finishes its remaining work, and terminates.
Through this whole journey, the process alternated between the ready queue (waiting for CPU) and a device queue (waiting for I/O) multiple times, exactly the pattern that motivates the CPU-bound vs I/O-bound process distinction covered elsewhere.
Where this matters in real systems
This queue-based model is a direct, accurate description of how real operating system kernels actually organize process state internally. Linux's process states (RUNNING, READY, and various flavors of WAITING/BLOCKED depending on what a process is waiting for) map almost one-to-one onto this queue model, and tools like ps or top that show a process's current state are really just reporting which of these conceptual queues that process currently belongs to.
What interviewers actually ask about scheduling queues
- "What's the difference between the job queue and the ready queue?" The job queue holds every process in the system regardless of memory residency; the ready queue holds only processes currently in memory and ready to run, waiting specifically for the CPU.
- "What is a device queue?" A queue of processes waiting for a specific I/O device to become available or complete an operation.
- "Describe the typical queue journey of a process that performs I/O." Ready queue, to CPU, to a device queue (while I/O happens), back to ready queue, repeating as needed, until the process finishes.
- "How does this relate to real process states you'd see in a tool like
top?" Real OS process states (running, ready/runnable, blocked/waiting) map directly onto which of these conceptual queues a process currently belongs to.
Key takeaways
- The job queue holds all processes in the system; the ready queue holds processes in memory waiting for the CPU; device queues hold processes waiting on specific I/O.
- A process cycles between the ready queue and device queues as it alternates between computing and performing I/O.
- This queue model closely matches real operating system process states you can observe with tools like
psortop. - Understanding these queues clarifies why a process's state changes constantly during its lifetime, not just once.
More in Process Scheduling
Browse all Operating Systems topics
Log in to save which topics you've read across every subject.
Frequently asked questions
What's the difference between the job queue and the ready queue?
The job queue holds every process in the system regardless of memory residency; the ready queue holds only processes currently in memory and ready to run, waiting specifically for the CPU.
What is a device queue?
A queue of processes waiting for a specific I/O device to become available or complete an operation.
Describe the typical queue journey of a process that performs I/O.
Ready queue, to CPU, to a device queue (while I/O happens), back to ready queue, repeating as needed, until the process finishes.
How does this relate to real process states you'd see in a tool like `top`?
Real OS process states (running, ready/runnable, blocked/waiting) map directly onto which of these conceptual queues a process currently belongs to.