Back

Real World Examples

Operating systems can use queues to schedule processes and manage resource allocation. In the simplest form, processes can be placed at the back of the queue as they arrive, and the processor executes them one by one. This is First Come, First Served scheduling. However, this approach can be inefficient because large processes may cause long wait times.

There are various other algorithms for scheduling, and they all use queues. For example, the OS can use a method of scheduling called Multilevel Feedback Queues. This consists of several different queues holding processes, with each queue representing levels of priority. Processes taking up too much CPU time are shifted to a lower priority queue, and higher priority processes can be moved to a higher priority queue.

Queues are used in printers. As requests to print arrive at the printer from various computers, they are added to the back of the queue to wait. The FIFO approach ensures that items are printed in the correct order, ensuring fairness as those who sent a print request first get their items quickly.

Network protocols, such as TCP, use queues to manage packet transmission. Queues help to deliver packets in the original order, and the rate of delivery of packets over the network can be managed to tackle traffic issues. Queues are also used in networks when buffering packets at routers or switches. When multiple packets arrive at these hardware devices, they can’t be dealt with immediately so are held in a queue and wait their turn to be processed.