You are on page 1of 9

Operating System Lab-5

Ex. No: 5 Scheduling Algorithms


M Date: 31-01-2022
NAME: RAMINEDI SANTHOSH
REG NO: 20BCE1477

Consider a system containing four processes P1, P2, P3 and P4 with burst time 9, 4, 2 and 8
time units (ms) arrive at same time. For the given Process, Arrival Time and Burst time,
construct the Gantt Chart for

• First Come First Serve


• Shortest Job First using (Non-Preemptive)
• Priority Scheduling (Non-Preemptive)
The processes are allowed to compute the work based on the priority 3, 2, 4, 1 respectively.

Calculate the average waiting time for the scheduling method and justify which Scheduling
method could be recommended ensuring higher performance of the system. Evaluate with
respect to Average waiting time and turn-around time.

FCFS, SJF, Priority


Process BT AT Priority CT TAT=CT- TWT=TAT-
AT BT
P0 9 0 3
P1 4 0 2
P2 2 0 4
P3 8 0 1

1: Highest priority
4: Lowest priority

Scheduling code in c language


Input:
Output:
1. FCFS scheduling
2. Priority Scheduling
3. SJF Scheduling
Overall analysis

FCFS Scheduling

Burst Time Completion Arrival Turn Around Time Waiting Time


Process (BT) Time (CT) Time (AT) (TAT) = (CT-AT) (WT) = (TAT – BT)
(in ms) (in ms) (in ms) (in ms) (in ms)
P0 9 9 0 9 0
P1 4 13 0 13 9
P2 2 15 0 15 13
P3 8 23 0 23 15
Total 60 37
= 60 / 4 = 37 / 4
Average
=15 =9.25
Priority Scheduling
Burst Priority Arrival Turn Around Waiting Time
Completion
Time Time Time (TAT) = (WT) = (TAT –
Process Time (CT)
(BT) (AT) (CT-AT) BT)
(in ms)
(in ms) (in ms) (in ms) (in ms)
P0 9 3 21 0 21 12
P1 4 2 12 0 12 8
P2 2 4 23 0 23 21
P3 8 1 8 0 8 0
Total 64 31
= 64 / 4 = 41 / 4
Average
=16 =10.25

SJF Scheduling
Burst Time Completion Arrival Turn Around Time Waiting Time
Process (BT) Time (CT) Time (AT) (TAT) = (CT-AT) (WT) = (TAT – BT)
(in ms) (in ms) (in ms) (in ms) (in ms)
P0 9 23 0 23 14
P1 4 6 0 6 2
P2 2 2 0 2 0
P3 8 14 0 14 6
Total 50 31
= 41 / 4 = 22/ 4
Average
=11.25 =5.5

Comparative Study

Turn Around Time Waiting Time (WT) =


Process Scheduling Algo.
(TAT) = (CT-AT) (TAT – BT)
FCFS 15 9.25
SJF (non-preemptive) 11.25 5.5
Priority 16 10.25
Comparatively, SJF is better than FCFS and Priority

You might also like