ALGORITHM
ALGORITHM
WT
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
Ghatt chart
P1 P2 P3 P4 P5
0 8 9 11 14 20
P1 2 1
P3 1 4 P1 5
P3 3
P1 P3 P2 P3 P1
0 1 2 3 6 11
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
P1 P3 P2 P1 P4 P5 P1
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
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.
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
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
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