applications of queue

31
Applicatio ns Of Queue

Upload: saksham-khurana

Post on 14-Apr-2017

284 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Applications of queue

Applications Of Queue

Page 2: Applications of queue

IntroductionWhat is a Queue ?

Queue is data structure in which the element that is inserted first will be the first one to be deleted .

• 2 access points called front or rear .• Inserted in rear• Deleted from front• Varying length• FIFO characteristic

Page 3: Applications of queue

APPLICATIONS

• Input Queue•Network Queueing•Queues In Operating System

Page 4: Applications of queue

INPUT QUEUE

Input queue is a collection of processes in storage that are waiting to be brought into memory to run a program.

Page 5: Applications of queue

Used In

•Operating System Scheduling

•Networking Devices

Page 6: Applications of queue

Operating System Scheduling 1.

First-Come, First-Served

Shortest remaining timeFixed priority pre-emptive schedulingRound-robin scheduling

Multilevel queue scheduling

a.

b.

c.

d.

e.

Page 7: Applications of queue

First-Come, First-Served

FIFO architecture

Result in poor performance of OS cause each process is treated equaliy.

a.

Page 8: Applications of queue

Shortest remaining timeb.

Tries to predict the processing time of developments and places them into the queue from the smallest to largest processing time.

This method estimates and predicts based on prior history records.

Performance is not stable but better improves process waiting time than First-Come-First-Serve.

Page 9: Applications of queue

Fixed priority pre-emptive scheduling

c.

♠Assigns different priorities to the processes based on their processing time and arranges them into the queue in order of their priorities.

♠CPU server processes from higher to lower priority, and processes which have the same priority are served as First-Come-First-Serve.

♠The CPU will temporary stop serving low priority process when higher priority process coming into the queue.

Page 10: Applications of queue

Round-robin schedulingd.

∞Give a same amount of time for each process and cycle through them.

∞This method is heavily bases on allot time giving to each process.

∞Too short allot time will fragment the processes, and too long allot time will increase waiting time for each process to be executed .

Page 11: Applications of queue

Multilevel queue scheduling

Many queues are used in Multilevel queue scheduling method and each queue has its own scheduling algorithm.

Multilevel queue scheduling is more complex compare to other methods, but it provides flexibility for OS to serve different data in complicated situation.

e.

Page 12: Applications of queue

Networking Devices 2.

First in, First out queue (FIFO)

Weighted fair queue (WFQ)Priority queue (PQ)

Custom queue (CQ)

a.

b.

c.

d.

Page 13: Applications of queue

First in, First out queue (FIFO) a.

Packets are taken out from the queue in the order that they are coming from the queue .

Every packet is treated the same priority.

If a system doesn’t treats every packet the same, users can experience the delay in transmitting such as: voice packets.

Page 14: Applications of queue

Weighted fair queue (WFQ) b.

Weighted fair queue means the scheduler will assign weight for each type of packet.

Base on the weight, it will determine how to put packet into the queue and serve them.

Weighted fair queue uses the min-max-fair-share algorithm to distribute packets.

The min fair-share means the network OS will distribute equally minimum resource for each type of packet.

The max fair-share means the network OS will provide more resource for packets that need to transfer large amount of date at that moment .

Page 15: Applications of queue

Priority queue (PQ)c.

Priority queue is divided into 4 sub queues with different priorities.

Data in each queue are only served when the higher priority queues are empty.

If data come into the empty higher priority queue while the network OS is transferring data of lower priority queue, network OS will hold data of the lower priority queue and process data in higher priority queue first.

The network OS does not care how long lower priority queues have to wait for their turn because it always finishes each queue from highest to lowest priority first before moving to the next queue.

Within each queue, packets are forwarded based on First-In-First-Out basis.

Page 16: Applications of queue

Custom queue (CQ) d.

o Custom queue is divided into 17 different sub queues.

o The first queue, queue 0, is reserved for the network OS to transmit system packet, the other 16 queues are for user-defined packets.

o User can define various important packets and assign them into each queue.

o Each queue is serviced based on how much packets are served in each queue.

o If that limit is met, the network OS will hold packets of current queue and services the next queue until that queue is empty or it reaches its packet limit.

o If one queue is empty, the network OS will skip that queue and service the next queue.

Page 17: Applications of queue

NETWORK QUEUEING

The term ‘network of queues’ OR Network Queueing describes a situation where the input from one queue is the output from one or more others.

Page 18: Applications of queue

Used In

•Computer Networks

•Network Communication

Page 19: Applications of queue

Computer Networks 1.

Time Sharing

First in First Out

Last in First Out

Smallest Job First

Priority Queues

a.

b.

c.

d.

e.

Page 20: Applications of queue

Time Sharinga.

• Time sharing is when the CPU is dedicated for one task for a fixed period of time after which it is switched to another task.

• The task can then be recycled I.e. put back in the queue so that the remainder of it is executed at another time.

• This can be repeated until the task is complete.

Page 21: Applications of queue

First in First Out

A first in first out queue is the same basis we would use in real life for a cinema queue or a phone box in that the tasks are executed in the order that they arrived .

b.

Page 22: Applications of queue

Last In First Out

A last in first out queue is precisely the opposite of FIFO as a new job is started as soon as it is queued.

c.

Page 23: Applications of queue

Smallest Job First

A smallest job first queue orders the jobs in terms of the smallest one first which means you get as many jobs complete as quickly as possible even though in total the time taken is the same.

d.

Page 24: Applications of queue

Priority Queuee.

Let us suppose there is a queue of events recieved from each input device(i.e. mouse, keyboard etc).

Imagine a system with two queues, one for the mouse and one for the keyboard which lead into a master queue of input events.

Mouse movement may be given priority over mouse button presses.

Any event from the mouse may be given priority in the master queue over any event in the keyboard queue.

Page 25: Applications of queue

Network Communication 2.

Circuit Switching

Packet Switching

a.

b.

Page 26: Applications of queue

Circuit Switching

When a call is made from a source to a destination it must traverse several nodes along the way.

Which nodes it traverses is determined by the availability of free channels along the way.

Each node has a queue for calls requesting a channel.

Once a channel has been opened the call can progress to the next node and wait for a channel there.

The channel remains open until the source or destination (once reached) closes the call.

a.

Page 27: Applications of queue

Packet Switching

Messages are transmitted through intermediate stages and the route a message takes depends entirely upon the current load on the system.

The route allocation is dynamic.

At this stage a queue comes in play which store the amount each process takes and also the process currently in each route .

After this it allocates each process according to the the load in each queue and the time the process takes.

b.

Page 28: Applications of queue

Operating System Process Scheduling

The process scheduling is the activity of the process manager that handles the removal of the running process from the CPU and the selection of another process on the basis of a particular strategy.

Process scheduling is an essential part of a Multiprogramming operating system. Such operating systems allow more than one process to be loaded into the executable memory at a time and loaded process shares the CPU using time multiplexing

Page 29: Applications of queue

Scheduling

Queue

Page 30: Applications of queue

Two State Process Model

• RunningWhen new process is created by Operating System that process enters into the system as in the running state.

• Not RunningProcesses that are not running are kept in queue, waiting for their turn to execute. Each entry in the queue is a pointer to a particular process. Queue is implemented by using linked list. Use of dispatcher is as follows. When a process is interrupted, that process is transferred in the waiting queue. If the process has completed or aborted, the process is discarded. In either case, the dispatcher then selects a process from the queue to execute.

Page 31: Applications of queue

THANK YOU