0% found this document useful (0 votes)
22 views2 pages

CHP 2.1

Uploaded by

Rutuja Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

CHP 2.1

Uploaded by

Rutuja Jadhav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Application of Queue:

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 )

Data Structures of Queues


Job scheduling is one application of queues, as explained on this page.
A queue is natural data structure for a system serving incoming requests. Most of the
process scheduling or disk scheduling algorithms in operating systems use queues.

We can implement a round-robin scheduler using a queue, Q, by repeatedly performing the


following steps:

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:

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.

You might also like