This document discusses priority queues. It defines a priority queue as a queue where insertion and deletion are based on some priority property. Items with higher priority are removed before lower priority items. There are two main types: ascending priority queues remove the smallest item, while descending priority queues remove the largest item. Priority queues are useful for scheduling jobs in operating systems, where real-time jobs have highest priority and are scheduled first. They are also used in network communication to manage limited bandwidth.
2. A priority queue is a queue in which insertion
and deletion of items from any position in the
queue are done based on some property (such as
priority of task).
Priority queue contains data items which have
some preset priority. While removing an element
from a priority queue, the data item with the
highest priority is removed first.
In a priority queue, insertion is performed in the
order of arrival and deletion is performed based
on the priority.
3. Rules: -
1. An element with higher priority will processed before an
element with a lower priority.
2. Two elements with the same priority are processed on a
First Come First Serve basis(FCFS).
The advantages of priority queue is :-
Easy to implement.
Processes with different priority can be efficiently
handled.
4. 1. Ascending Priority Queue In this type of
priority queue, elements can be inserted into any
order but only the smallest element can be
removed.
2. Descending Priority Queue In this type
of priority queue, elements can be inserted into
any order but only the largest element can be
removed.
5. Using Arrays :- Insertion Operation
While inserting elements in priority queue we
will add it at the appropriate position
depending on its priority
• It is inserted in such a way that the elements
are always ordered either in Ascending or
descending sequence
Deletion Operation While deletion, the
element at the front is always deleted.
6.
7.
8. 1. Priority queue is in scheduling the jobs in
operating system . Operating system allocates
priority to jobs , the jobs are placed in the queue
and the position of the jobs in the priority queue
determines their priority.
In operating system there are three kinds of jobs
.there are real time jobs, foreground jobs, and
background jobs. The operating system always
schedules the real time jobs first . If there is no
real time job pending then it schedule foreground
jobs . Lastly if no real time or foreground jobs are
pending then operating system schedules the
background jobs.
2. In network communication to manage limited
bandwidth for transmission the priority queue is
used .