CHP 2.1
CHP 2.1
Queue is used when things don’t have to be processed immediately, but have to be
processed in First In First Out order like Breadth First Search. This property of Queue
makes it also useful in following kind of scenarios.
1) When a resource is shared among multiple consumers. Examples include CPU
scheduling, Disk Scheduling.
2) When data is transferred asynchronously (data not necessarily received at same rate as
sent) between two processes. Examples include IO Buffers, pipes, file IO, etc.
3) In Operating systems:
a) Semaphores
b) FCFS ( first come first serve) scheduling, example: FIFO queue
c) Spooling in printers
d) Buffer for devices like keyboard
4) In Networks:
a) Queues in routers/ switches
b) Mail Queues
5) Variations: ( Deque, Priority Queue, Doubly Ended Priority Queue )
1. dequeue()e = Q.
2. Service element e
3. Q.enqueue(e)
A Round-Robin Scheduler
Job Scheduling
Operating systems access many jobs regularly. These jobs are added into a queue known
as the job queue. One by one, jobs are retrieved from the job queue and added to the ready
queue, which assigns them to the processor. Then, an algorithm partitions the ready queue
into several separate queues. The nature of jobs in this multilevel queue is different. Each
job is given a different priority based on its nature. These jobs are in the form of processes.
There can be many types of processes queues, like the system queue, which contains all
system processes. Processes are permanently assigned to a specific queue based on
their properties. Each queue has its own specific scheduling algorithm. Consider the
following illustration of multilevel priority queue scheduling:
Each queue has absolute priority over lower priority queues. No processes in batch queues
will be able to run until the queues above them are empty. Another possibility is to time slice
between the queues by allotting each process with a certain portion of CPU time.