0% found this document useful (0 votes)
15 views13 pages

Unit III - Applications of Queue

Uploaded by

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

Unit III - Applications of Queue

Uploaded by

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

Applications of Queue

Introduction
• A queue is a linear data structure that follows the “first-in, first-out” (FIFO)
principle. It is a collection of elements that supports two primary
operations – Enqueue and Dequeue.

• In the enqueue operation, an element is added to the back of the queue,


while in the dequeue operation, an element is removed from the front of
the queue.
The basic operations of a queue include:

• Enqueue: Add an element to the back of the queue.

• Dequeue: Remove the element at the front of the queue.

• Peek: Return the element at the front of the queue without removing it.

• Size: Return the number of elements in the queue.

• isEmpty: Check if the queue is empty.


Applications of Queue data structure
Task Scheduling: Queues can be used to schedule tasks based on priority or
the order in which they were received.

Resource Allocation: Queues can be used to manage and allocate resources,


such as printers or CPU processing time.

Message Buffering: Queues can be used to buffer messages in communication


systems, such as message queues in messaging systems or buffers in computer
networks.

Event Handling: Queues can be used to handle events in event-driven systems,


such as GUI applications or simulation systems.
Traffic Management: Queues can be used to manage traffic flow in
transportation systems, such as airport control systems or road networks.

Operating systems: Operating systems often use queues to manage processes


and resources. For example, a process scheduler might use a queue to manage
the order in which processes are executed.

Network protocols: Network protocols like TCP and UDP use queues to manage
packets that are transmitted over the network. Queues can help to ensure that
packets are delivered in the correct order and at the appropriate rate.
Printer queues :In printing systems, queues are used to manage the order
in which print jobs are processed. Jobs are added to the queue as they are
submitted, and the printer processes them in the order they were received.

Web servers: Web servers use queues to manage incoming requests from
clients. Requests are added to the queue as they are received, and they are
processed by the server in the order they were received.

Real world applications like Ticket counter, Restaurant

Asynchronous data transfer (Files input and output)


FCFS (FIRST-COME, FIRST-SERVED) Scheduling
• FCFS is considered as simplest CPU-scheduling algorithm. In FCFS
algorithm, the process that requests the CPU first is allocated in the CPU
first. The implementation of FCFS algorithm is managed with FIFO (First in
first out) queue.

• Real Life Example Of FCFS Scheduling

• As a real life example of FCFS scheduling a billing counter system of


shopping mall can be observed. The first person in the line gets the bill done
first and then the next person gets the chance to get the bill and make
payment and so on.
FCFS Scheduling Mathematical Examples

• Arrival time (AT) − Arrival time is the time at which the process arrives in
ready queue.

• Burst time (BT) or CPU time of the process − Burst time is the unit of
time in which a particular process completes its execution.

• Completion time (CT) − Completion time is the time at which the process
has been terminated.

• Turn-around time (TAT) − The total time from arrival time to completion
time is known as turn-around time.
• TAT can be written as,

• Turn-around time (TAT) = Completion time (CT) – Arrival time (AT) or,
TAT = Burst time (BT) + Waiting time (WT)

• Waiting time (WT) − Waiting time is the time at which the process waits
for its allocation while the previous process is in the CPU for execution. WT
is written as,

• Waiting time (WT) = Turn-around time (TAT) – Burst time (BT)

• Response time (RT) − Response time is the time at which CPU has been
allocated to a particular process first time.
• Consider the given table below and find Completion time (CT), Turn-
around time (TAT), Waiting time (WT), Response time (RT), Average Turn-
around time and Average Waiting time.

Process ID Arrival time Burst time


P1 2 2
P2 5 6
P3 0 4
P4 0 7
P5 7 4
Gantt chart
• Average Waiting time = (9+8+0+4+12)/5 = 33/5 = 6.6 time unit (time unit
can be considered as milliseconds)

• Average Turn-around time = (11+14+4+11+16)/5 = 56/5 = 11.2 time unit


(time unit can be considered as milliseconds)

You might also like