0% found this document useful (0 votes)
7 views

ALGORITHM

enklakdawD

Uploaded by

god889870
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

ALGORITHM

enklakdawD

Uploaded by

god889870
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

PROCESS AT BT CT TAT WT RT A.TAT A.

WT

P1 0 8 8 8-0=8 8-8=0 0 56/5=11.2 32/5=6.4

P2 1 1 9 9-1=8 8-1=7 7

P3 2 3 11 14-2=12 12-3=9 9

P4 3 2 14 11-3=8 8-2=6 6

P5 4 6 20 20- 16-6=10 10
14=16

SJF (primitive) [Shortest Job First]

Ghatt chart

P1 P2 P3 P4 P5
0 8 9 11 14 20

SRTF with pre-emptive


Shortest remaining time first
 Whenever new process arrives, there may be pre-emption of the running
process.
 SJF can be either pre-emptive or non pre-emptive. This is a type of pre-
emptive SJF scheduling algorithm.
 If a new process has a short CPU burst than the left CPU burst time of
currently executing process, pre-emptive SJF scheduling will pre-empt
the currently running process.
P1 0 6

P1 2 1

P3 1 4 P1 5

P3 3

P1 P3 P2 P3 P1
0 1 2 3 6 11

Consider an example with 5 process P1, P2, P3, P4 and P5.


Process AT BT CT TAT WT RT A.TAT A. WT
(CT- (TAT-BT)
AT)
P1 2 1 3 1 0 0
P2 1 5 16 15 10 10
P3 4 1 5 1 0 0 33/6=6.6 17/5=3.4
P4 0 6 11 11 5 0
P5 2 3 7 5 2 1

P4

0 1
 Whenever new process arrives, there may be pre-emption of the running
process.
 To submit one process to CPU, we need to check every one unit of time
for what, is there any higher priority purpose arrives or not.
 Considering the above example, we need to find the guntt chart based
on the higher priority basis.
 Now according to unit time 0 there is only one process arrives at a ready
queue i.e., P4 with the burst time 6. Then it will check how any one unit
of time, any higher priority process arrives or not.
 At this point of time process P4 will be pre-empted.
 P4 completed their 1 unit of execution, still remains the 5 units.
 At the time 1 unit is arrived then checkout newly processed burst
time. Here the executed process P4and newly arrived process P2 has
the same burst time as 5.
 To break the time, apply FCFS order. As the rule indicates the process is
arrives at first, we will consider to execute. Therefore, arrival time of P4
is less than the arrival time of P2

P4 P4
0 1 2
 At the unit of time 2 P1 and P5 has arisen and also P4 is completed one
unit. Now the remaining time for P4 is 4
 Next, we need to calculate the shortest burst time, P1 will execute.

P4 P4 P1
0 1 2 3
 P1 is completed their full execution and terminated the connection from
CPU.
 Compare the burst time with process P4, P2, P5. P5 has the least burst
time.

P4 P4 P1 P5
0 1 2 3 4
 To check the arrival time for is there any process, the process 3 arrives at 4.

P4 P4 P1 P5 P3
0 1 2 3 4 5
 Now there are only remaining 3 process P2, P4 and P5.
 Next we consider the shortest burst time, P5 will execute with 2 unit of
time.
P4 P4 P1 P5 P3 P5
0 1 2 3 4 5 7
 Here total time is same as the total burst time i.e., 16.

P4 P4 P1 P5 P3 P5 P4 P2
0 1 2 3 4 5 7 11 16
Question:
Process AT BT CT TAT WT RT A.TAT A.WT
P1 0 75 205 205
P2 10 40 75 65
P3 10 25 35 25
P4 80 20 100 20
P5 85 45 145 60

P1 P2 P3 P4 P5

0 75 115 140 160 205

P1 P3 P2 P1 P4 P5 P1

0 10 35 75 80 100 145 205

Consider an example to solve the priority scheduling algorithm.


PROCESS AT BT Priority CT TAT WT RT A.TAT A.WT
P1 0 8 3 15
P2 1 2 4 17
P3 3 4 4 21
P4 4 1 5 22
P5 5 6 2 12
P6 6 5 6 27
P7 10 1 1 11

P1 P1 P1 P1 P5 P5 P7 P5 P1 P2 P3 P4 P6
0 1 3 4 5 6 10 11 12 15 17 21 22 27

Round Robin Algorithm


Mode: Pre-emptive
PROCESS AT BT
P1 0 8
P2 5 2
P3 1 7
P4 6 3
P5 8 5

Ready Queue

P1 P3 P1 P2 P4 P3 P5 P1 P3 P5
QT = 3 time
Gantt Chart

P1 P3 P1 P2 P4 P3 P5 P1 P3 P5
0 3 6 9 11 14 17 20 22 23 25

Multi-level Algorithm
 The process is divided and keeps in a multiple queue.
 It partition the ready queue into several separate queue i.e., foreground
or background process.
 Process are permanently assigned to one queue depending on memory
size, priority, process time etc.
 There are three main types of set of process
System Process

Interactive Process

Batch process

 Each queue has its own algorithm. The algorithms is used for each
process. It is implemented by the implementor.
 If one process is belongs to one type of queue, during the execution it
cannot migrate or change from one queue to another queue
(permanently assigned).
 In multi-level feedback queue, we are able to migrate the process from
one queue to another.

Multiple processor scheduling


There are two types of processor:
1. Homogeneous processors – Identical functionality or all systems having
the same configuration.
2. Heterogeneous processors – Different functions and properties.
To execute multiprocessor with multi-processing process, there are two
approaches:
1. Symmetric multiprocessing(SMP)
 Each process has its own memory and ready queue.
 Two processors do not select same process.
2. Asymmetric multiprocessing(AMP)
 It is master-slave approach
Scheduled algorithm

Page 3 2 1 3 4 1 6 2 4 3 4 2 1 4 5 2 1 3 4

F1 3 3 3 3 4 4 4 4 4 3 3 3 3 3 5 5 5 5 4

F2 2 2 2 2 2 6 6 6 6 4 4 4 4 4 2 2 2 2

F3 1 1 1 1 1 2 2 2 2 2 1 1 1 1 1 3 3

X X X ✔️ X ✔️ X X ✔️ X X ✔️ X ✔️ X X ✔️ X X

Recently used algorithm

Pag
3 2 1 3 4 1 6 2 4 3 4 2 1 4 5 2 1 3 4
e

F1 3 3

F2 2

F3 1

Page faults = 14/19

Hit ratio = 5/19

Optical page replacement algorithm


Page 3 2 1 3 4 1 6 2 4 3 4 2 1 4 5 2 1 3 4

F1 3 3 3 3 4 4 4 4 4 4 4 4 4 4 5 5 5 3 4

F2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

F3 1 1 1 1 6 6 6 3 3 3 1 1 1 1 1 1 1

X X X ✔️ X ✔️ X ✔️ ✔️ X ✔️ ✔️ X ✔️ X ✔️ ✔️ X X

Page 3 2 1 3 4 1 6 2 4 3 4 2 1 4 5 2 1 3 4

F1 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3

F2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2

F3 1 1 4 1 6 6 4 4 4 4 1 4 5 5 1 1 4

You might also like