Multilevel Feedback Queue Scheduling
Multilevel Feedback Queue Scheduling
□ Basic Concept
□ CPU-I/O burst cycle
□ CPU scheduler
□ Preemptive scheduling
□ Dispatcher
Basic Concepts
□ Scheduling is a important function of O.S.
□ In multiprogramming environment , many
process are in memory.
□ So CPU scheduling is necessary. By doing
CPU scheduling , O.S switching the CPU
from one process to other.
□ In a single processor system, only one process
can run until the CPU is free and can be
rescheduled.
Basic Concepts
□ The objective of multiprogramming is to have some process
running at all times to maximize CPU utilization.
□ The CPU executes one program at a time.
□ If that program requires I/O then O.S switches the CPU to
another ,This pattern continues.
□ Every time one process has to wait, another process can take
over use of the CPU.
□ Scheduling of this kind is a fundamental O.S function
□ Almost all computer resources are schedules before use.
CPU I/O BURST TIME
□ Maximum CPU utilization obtained with
multiprogramming
□ Process execution consists of a cycle of CPU
execution and I/O wait
□ Processes alternate between these two states.
□ Process execution begins with a CPU burst , that is
followed by an I/O burst, which is followed by
another CPU burst, then another I/O burst so on.
□ Eventually the final CPU burst ends with system
request to terminate execution
□ The duration of CPU burst vary from process to
process or computer to computer
□ If the program is I/O bound then it has short CPU
burst, when the program or process is CPU bound
then it has very short I/O burst.
□ This distribution is important in selecting
appropriate CPU scheduling algorithm
CPU SCHEDULER
□ Whenever the CPU becomes idle , the O.S must select one of the
processes in the ready queue to be executed.
□ The selection process is carried out by the short term scheduler (CPU
scheduler)
□ The scheduler selects a process from the processes in memory that
are ready to execute and allocates the CPU to that process.
□ The ready queue is not necessarily a FIFO queue. As we shall see when
we consider the various scheduling algorithm, a ready queue can be
implemented as a FIFO queue , a priority queue, a tree or simply an
unordered linked list.
□ Conceptually , however all the processes in the ready queue are lined
up waiting for a chance to run on the CPU.
□ The records in the queues are generally process control block of the
process.
PREEMPTIVE AND NON-PREEMPTIVE SCHEDULING
1. Process switches from running state 1. Process switches from running state
to ready state to waiting state.
2. Also process switches from waiting 2. In this a process may get
state to ready state. terminated
3. Here, multiple process can run, one 3. In this when the process assigned to
process can be pre-empted to run CPU, it keeps process busy, till it gets
another process. terminated.
4. It needs specific Platform 4. It is platform independent (hardware
5. E.g. Windows 95 and MAC independent)
5. E.g. Windows 3.X versions.
DISPATCHER
□ Dispatcher module gives control of the CPU to
the process selected by the short-term
scheduler; this involves:
□ switching context
□ switching to user mode
□ jumping to the proper location in the user program to restart that
program
□
• To find out performance of the scheduling
algorithm we use Gantt chart .
• Gantt chart is nothing but a chart used to
describe a schedule. It will represent the
sequence in which the jobs will be scheduled
by the CPU.
FIRST-COME, FIRST-SERVED (FCFS) SCHEDULING
Proc Arriva CPU time Finish Time Waiting Time Turn Around
ess l time (or) burst FT WT=TAT-BT Time
time (in ms) TAT=FT-AT
P2 0 2 2 0 2
P1 1 5 7 1 6
P3 2 3 10 5 8
Proc Arriva CPU time Start Time Finish Time Waiting Time Turn Around
ess l time (or) burst ST FT WT=ST-AT Time
time (in ms) TAT=FT-AT
P1 0 2
P2 1 2
P3 4 3
P4 5 4
Proc Arriva CPU time Start Time Finish Time Waiting Time Turn Around
ess l time (or) burst ST FT WT=ST-AT Time
time (in ms) TAT=FT-AT
P1 0 5
P2 0 10
P3 0 8
P4 0 3
P1 0 2
P2 1 2
P3 5 3
P4 6 4
0 3 4 9 13 17 19
Proc Arriva CPU time Finish Time Waiting Time Turn Around
ess l time (or) burst FT WT=TAT-BT Time
time (in ms) TAT=FT-AT
P1 4 5
P2 6 4
P3 0 3
P4 6 2
P5 5 4
0 3 4 9 13 17 19
Proc Arriva CPU time Finish Time Waiting Time Turn Around
ess l time (or) burst FT WT=TAT-BT Time
time (in ms) TAT=FT-AT
P1 5 1
P2 6 0
P3 2 2
P4 4 0
□ Process with longer CPU burst time requirement will go into starvation
□ No idea of priority, process with large burst time have poor response time
SJF (non-preemptive )Gantt chart
Proc Arriva CPU time Finish Time Waiting Time Turn Around
ess l time (or) burst FT WT=TAT-BT Time
time (in ms) TAT=FT-AT
P1 1 3
P2 2 4
P3 1 2
P4 4 4
0
Proc Arriva CPU time Finish Time Waiting Time Turn Around
ess l time (or) burst FT WT=TAT-BT Time
time (in ms) TAT=FT-AT
P1 2 2
P2 0 1
P3 2 3
P4 3 5
P5 4 4
Proc Arriva CPU time Finish Time Waiting Time Turn Around
ess l time (or) burst FT WT=TAT-BT Time
time (in ms) TAT=FT-AT
P1 1.5 5
P2 0 1
P3 2 2
P4 3 4
0
Pro Arriv CPU time CPU time Finish Time Waiting Turn
ces al (or) burst (or) burst Time Around
FT
s time time (in time (in Time
WT=TAT-BT
ms) ms) TAT=FT-
AT
P1 0 8
P2 1 4
P3 2 9
P4 3 5
0 13
Proce Arrival CPU time CPU time Finish Time Waiting Time Turn Around
ss time (or) burst (or) burst FT WT=TAT-BT Time
time (in ms) time (in ms) TAT=FT-AT
P1 0 7
P2 1 5
P3 2 3
P4 3 1
P5 4 2
P6 5 1
Total TWT= TTAT=
Proce Arrival CPU time CPU time Finish Time Waiting Time Turn Around
ss time (or) burst (or) burst Time
FT WT=TAT-BT
time (in ms) time (in ms) TAT=FT-AT
P1 2 1 1,0
P2 1 5 5
P3 4 1 1,0
P4 0 6 6,5,4
P5 2 3 3,2
Total TWT= TTAT=
0
Proce Arrival CPU time CPU time Finish Time Waiting Time Turn Around
ss time (or) burst (or) burst FT WT=TAT-BT Time
time (in ms) time (in ms) TAT=FT-AT
P1 2 1 1,0
P2 1 5 5
P3 4 1 1,0
P4 0 6 6,5,4
P5 2 3 3,2
Total TWT= TTAT=
□ Indefinite blocking or starvation. A process that is ready to run but lacking CPU
can be considered blocking or waiting for CPU.
□ In case if system crashes then all unfinished or pending low priority processes will
be lost.
Priority( Non preemptive) Gantt
chart
0
Proc Arriva CPU time Priority Finish Time Waiting Time Turn Around
ess l time (or) burst FT WT=TAT-BT Time
time (in ms) TAT=FT-AT
P1 0 5 3
P2 0 10 2
P3 0 8 4
P4 0 3 1(High)
Total TWT= TTAT=
P1 0 8 3
P2 1 2 4
P3 3 4 4
P4 4 1 5
P5 5 6 2
P6 6 5 6
P7 10 1 1(high)
Total TWT= TTAT=
P1 1 4 5
P2 2 5 2(low)
P3 3 6 6
P4 0 1 4
P5 4 2 7
P6 5 3 8(high)
Total TWT= TTAT=
P1 1 4 5
P2 2 5 2(low)
P3 3 6 6
P4 0 1 4
P5 4 2 7
P6 5 3 8(high)
Total TWT= TTAT=
P1 0 5 10
P2 1 4 20
P3 2 2 30
P4 4 1 40(high)
P1 0 5 4
P2 2 4 2
P3 2 2 6(L)
P4 4 4 3
Total TWT= TTAT=
P1 0 8 4
P2 1 6 6
P3 3 7 3
P4 3 9 1(h)
Total TWT= TTAT=
0
P AT Priority BT BT FT WT=TAT-BT TAT=FT-AT
P1 0 3 8
P2 1 4 2
P3 3 4 4
P4 4 5 1
P5 5 2 6
P6 6 6(L) 5
P7 10 1(H) 1
Total TWT= TTAT=
□ Works well in case of time sharing system, client server architecture and
interactive system.
Disadvantages of SJF Algorithm
□ If the time quantum is too large then it is as good as FCFS policy
□ No idea of Priority.
Round Robin (time Quantum=2) Gantt chart
0
Proce Arrival CPU time CPU time Finish Time Waiting Time Turn Around
ss time (or) burst (or) burst FT WT=TAT-BT Time
time (in ms) time (in ms) TAT=FT-AT
P1 0 5
P2 1 3
P3 2 1
P4 3 2
P5 4 3
Total TWT= TTAT=
0
Proce Arrival CPU time CPU time Finish Time Waiting Time Turn Around
ss time (or) burst (or) burst FT WT=TAT-BT Time
time (in ms) time (in ms) TAT=FT-AT
P1 0 8
P2 5 2
P3 1 7
P4 6 3
P5 8 5
Total TWT= TTAT=
Queue 0
Queue 1
Queue 2
END OF CHAPTER 3