Queue (OS)

The OS maintains a number of queues, each of which is simply a list of processes waiting for some resource.

There are 3 main queues:

  1. Short-term queue
  2. Long-term queue
  3. I/O queue

Understand this in conjunction with the different Process States.

The short-term queue consists of processes that are in main memory and are ready to run as soon as the processor is made available.

How? This is where you should understand the Scheduler.

  • A common strategy is to give each process in the queue some time in turn; this is referred to as a Round Robin technique. In effect, the round-robin technique employs a circular queue.

Another strategy is to assign priority levels to the various processes, with the scheduler selecting processes in priority order.

The long-term queue is a list of new jobs waiting to use the processor

  • The OS adds jobs to the system by transferring a process from the long-term queue to the short-term queue
  • A portion of main memory must be allocated to the incoming process. Thus, the OS must be sure that it does not overcommit memory or processing time by admitting too many processes to the system

There is an I/O queue for each I/O device. More than one process may request the use of the same I/O device. All processes waiting to use each device are lined up in that device’s queue. Again, the OS must determine which process to assign to an available I/O device.

The OS receives control of the processor at the interrupt handler if an interrupt occurs. A process may specifically invoke some OS service, such as an I/O device handler, by means of a service call. In this case, a service call handler is the entry point into the OS. In any case, once the interrupt or service call is handled, the short-term scheduler is invoked to pick a process for execution.

The foregoing is a functional description; details and modular design of this portion of the OS will differ in various systems. Much of the research and development effort in operating systems has been directed at picking algorithms and data structures for this function that provide fairness, differential responsiveness, and efficiency.