Process Technical
Process Technical
2 20
Operating Systen
Operating System
2 . 9 Types
of
Scheduling
ming
multiprogramm i
eduler
concept.
selects one Process Fig. 2.9
is
m a x i m i z i n g
by
using
P r o c e s s o r
sched
process
utilization p r o c e s s .
CPU a
executing
not idle, it is
queue.
from the
ready
execution
processes
or
process
Waiting Waiting
When the
user
Last/ Tail
devices.
they put PCB No.
system, PCB
enters
into the
qurese No.
queue,
fob Open files
into the job of the
processes
system. maintains
system
Operating for
of queues
different types
The queue and d e v i c e queue
different purposes. 2.9.1 Ready
Fig.
device queue
queue,
are ready
etc. Fig. 2.9.1
shows ready
ko
queue
and device queue.
ready
and waiting to
execute are
kepti
The processes
which are
Linked list is Used
Ready queue : stored in
main memory.
3. Because of interrupt, process preempted from CPU and put into the readyear
queue.
2.9.1 Scheduiers
Schedulers are used to handles process scheduling. It is one type of sys
software and selects the jobs from the system and decide which process to
Schedulers are of three types -
1. Long term scheduler 2. Short term scheduler 3.
Medium term scheduler
TECHNICAL PUBLICATIONS An up thrust for
knowledge
Operating System 2-21 Prouess Managament
Suspended
process
Time out
term scheduler is also called job scheduler. It determines which process are
Long
Processes are selected from the queue and
admitted to the system for processing.
execution.
loads into the main memory for
controls the degree of muitiprogramming in multitasking
Long term scheduling
balanced mix of jobs, such as I/O bound and CPU bound.
systems. It provides a
time operating system. Time sharing
Long term scheduling is used in real
has no long term scheduler.
operating system
Medium term scheduler
Sometimes it the
part of swapping function.
removes
Medium term scheduler is
It also reduces the degree of multiprogramming.
process from memory.
and it is in memory then operating system takes
1/0 request
If process makes an
Once the process becomes suspended, it cannot
this process into suspended states. removed
In this situatiorn, the process is
make any progress towards completion. is
for other process. The suspended process
from memory and makes free space
is called
device i.e. hard disk. This process
stored in the secondary storage
swapping
thrust for knowledge
TECHNICAL PUBLICATIONS- An up
2- 22
Operating System rocess Ma
0
Short term scheduler
CPU scheduler. It sol cts
scheduler is also
called
the proce
Short term allocate the CPU for evo.
2. Speed is less than short Speed is very fast. Speed is in between both
term scheduler.
*** aewwwavowevonwe
3. It controls the degree of Less control over degree of Reduce the degree
multiprogramming. multiprogramming. multiprogramming.
wwwwwwwwwwwwww.ww.wv
*****
Absent or minimal in Minimal in
time sharing system.
time sharing Time sharing system us
system. mediumn term scheduler.
5. It select processes trom t select rom
* **
****
CPU bound.
CPU quite frequently. vwwnv wwwwwwwwww
wwwWww gcoc
******
differ.
Th
8.
Predictability: A
given pro
y s should run
parameters.
policy
m a y
Fairness
Shortest
job
are as
follows scheduling
scheduling
1. First In First Out (FIFO) R o u n d
4.
3. Priority scheduling
The processe:
Th a
Schedulin9 m e t h o d .
the
come
first at
is also called first
time
FIFO arrival
dispatched according
to their
This
1nis
algorithm is
algorithm is fi
algorithm.
CPU scheduling F
FIlF
FOO queue
queue.
useful in schedu.
in scheduli-
non-preemptive us
u se
ess
aa useful
e it
it not
n ot
be
b ec
caau
usse
FIFO
is
FIFO is simple to implement
systems. responseti
time.
operating short
batch
for most of the guarantee
block is linked to
tot
cannot
interactiveprocesses because it control
its process
system,
front of
the queue.
into the
process
nters
from the
When new
and it is
removed
Average waiting ti
end of the ready queue
FIFO algorithm.
with the tickets.
unpredictable
time is is buying
Real life analogy
Turnaround
Solution
Gantt chart:
P P2 P P Ps
4 11 14 17 22
Such diagram is called Gantt charts, showing when each process burst uses the CPU.
Waiting time:
ProcesS Waiting time
P1 0 -0 =0
P2 4- 0 = 4
P3 11 - 0 = 11
P4 14 0 = 14
anaaarasuammannsournmsna
Ps 17 0 = 17
owwwww.cewwwwwwwarmumaenaaannaaunnnaieammm.
P1 0+4 = 4
P2 ww.ww
4 +7 = 11
P3 11 + 3 = 14
P4 14+3 = 17
P5 17 +5 2 2
scheduling algorithm. It handles the process based on length o orteofst Job NNen
time. It reduces average waiting time over FIFO algorithm.
length heir C
CP
SJF is anon-preemptive CPU scheduling algorithm.
I t does not work in interactive system because users do not estis.
the CPU time required to run their processes. adv
SJF scheduling algorithm is used frequently in long term scheduling
Example 2.11.2 Calculate the average toaiting time and average turnaround time. Promi
Gantt chart for the same.
P1 5
P2 2
Pa
Solution
Gantt chart
P 2
P Pa
11
Waiting time 17
Process
Waiting time
P1 6-0 6
P2 0 -0 0
3 11 -0 11
P4 2-0 2
0+2 2
P3 11 +6 17
P4 2+4 6
P2 2
P3 6
wwww*
PA
Solution : For non-preemptive priority scheduling
Gantt chart
Pa P4 P P2
10 15 17
Waiting time:
Waiting time
Process
10 0 10
P 15 0 15
P2 '0-0 0
Pa 6-0 = 6
PA
time =
10+15+0+6 -= 7.75
Average waiting 4
Turnaround time
Process
10+ 5 = 15
P1
15 +2 17
P2
0 + 6 = 6
Pa
6 +4 10
P4
EYample 2.11.4 Consider the following set of process that arrive at time 0, with the length of
CPU burst given in milliseconds. Calculate the average waiting time and average
turnaround time. Provide the Gantt chart for the same. (Time slice = 2)
P1
P2
P3
P4
Solution
Gantt chart
PA P1 Pa
Pa PPP|
0 10 12 14 15
Waiting time
Process Waiting time
0 -0 8-2+.14 - 10 10
P
2-0 2
P2
4 0 10 -6+ 15- 12 11
P' +
6-0+ 12 8 10
P4
10 +5 15
2+2 =4
11 +6 17
Pa
10 +4 14
P4
coaveswwwwwww.w ***
wwwwww.coenocoaoweowaw