Process queues in OS

Process queues in operating systems are crucial for managing the execution of multiple processes efficiently. The operating system maintains different queues to handle processes based on their current state, which helps optimize CPU utilization and ensure smooth multitasking.


Types of Process Queues

  1. Job Queue: This queue contains all the processes admitted into the system. When a process is created, it is placed in the job queue, generally stored in secondary memory.
  2. Ready Queue: This queue holds all processes in the ready state loaded into the main memory to execute them. The Short Term Scheduler (STS) selects processes from this queue to run on the CPU.
  3. Device Queues: These queues are for processes waiting for I/O devices to become available. Each device may have its queue, and processes are moved here when they request I/O operations and cannot proceed until the operation is completed.

Process Scheduling

Process scheduling is the mechanism by which the OS decides which process runs at any given time. This involves moving processes between different queues based on their state:

  • Running: A process currently executing on the CPU.
  • Waiting: A process which is waiting for an event (like I/O completion) to occur.
  • Ready: A process ready to run but is not executing.

When a process state changes i.e. from a running state to a waiting state due to an I/O request, its Process Control Block (PCB) is unlinked from its current queue and linked to the new state queue.

Scheduling Strategies

  • Preemptive Scheduling: The OS can interrupt a currently running process to allocate CPU time to a higher-priority process. This ensures that critical tasks receive timely attention.
  • Non-Preemptive Scheduling: In this strategy, a running process cannot be interrupted until it voluntarily yields control of the CPU, either by completing its execution or entering a waiting state.