Operating Systems: Scheduling Algorithms
Operating Systems: Scheduling Algorithms
Scheduling Algorithms
Scheduling Algorithms
Scheduling Algorithms:
• First-Come, First-Served Scheduling
• Shortest-Job-First Scheduling
• Priority Scheduling
• Round-Robin Scheduling
• Multilevel Queue Scheduling
• Multilevel Feedback Queue Scheduling
Process BT
P1 24
P2 3
Wiating Time of P2 :0 Turnaround Time of P2 :0+3=3 P3 3
Wiating Time of P3 :3 Turnaround Time of P3 :3+3=6
Wiating Time of P1 :6 Turnaround Time of P1 :6+24=30
average waiting timeis
(0+3+6)/3=3 milli sec
Wiating Time of P1 :3
Turnaround Time of P1 :3+6=9
Wiating Time of P2 :16
Turnaround Time of P2 :16+8=24
Wiating Time of P3 :9
Turnaround Time of P3 :9+7=16
Wiating Time of P4 :0
Turnaround Time of P4 :0+3=3
average waiting timeis
(3 + 16 + 9 + 0)/4 = 7 milli sec
Dr.B.Hemantha Kumar. RVR&JC CE 6
Scheduling Algorithms
• Shortest-Job-First Scheduling(SJFS):
• Although the SJF algorithm is optimal, it cannot be
implemented at the level of short-term CPU scheduling.
With short-term scheduling, there is no way to know the
length of the next CPU burst.
• The next CPU burst is generally predicted as an
exponential average of the measured lengths of previous
CPU bursts.
• We can define the exponential average with the following
formula.
• Let tn be the length of the nth CPU burst, and let τn+1 be
our predicted value for the next CPU burst. Then, for α, 0 ≤
α ≤ 1, define τn+1 = tn + (1 − α) τn.
• The value of tn contains our most recent information, while τn stores
the past history. The parameter α controls the relative weight of
recent and past history in our prediction
Dr.B.Hemantha Kumar. RVR&JC CE 7
Scheduling Algorithms
• Preemptive SJFS
Process AT BT
If the processes arrive at P1 0 8
the ready queue at the P2 1 4
times as shown P3 2 9
P4 3 5
0 10 39 42 49 61
Waiting Time TAT: =WT+BT
–P1: 0 p1: 10,
P2 : 10, P2:39
P3: 39, P3: 42
P4: 42, P4: 49
P5:49 P5:61
Avg Wt (0+10+39+42+49)/5= 28
0 3 10 20 32 61
0 10 20 23 30 40 50 52 62
Waiting Time TAT: =WT+BT
–P1: 0+(40-10)+(52-2)=32 p1: 42,
P2 : 10, P2:39
P3: 20, P3: 23
P4: 23, P4: 30
P5:30+(50-40)=40 P5:52
Avg Wt (32+10+20+23+40)/5= 25
Dr.B.Hemantha Kumar. RVR&JC CE 23