Osy Microproject
Osy Microproject
Principal
(Dr. N. D. Misal)
Date:-
Place: Pandharpur
2. Shortest-job-first Scheduling
3. Priority Scheduling
4. Round-Robin Scheduling
• INTRODUCTION: -
#include<bits/stdc++.h>
using namespace std;
int main()
/*Visit - www.programmingwithbasics.com*/
int proc[p];
sort(cbt, cbt+p);
if(min>tmp[i]&&tmp[i]!=-1) (
min=tmp[i];
index=i;
gcIJ1=sum:
wt[j]=sum;
sum+=tmp[index];
tat{j]=sum;
tmp[index]=-1;
if(j==p)
break:
cout<<'P'<<index+1<<" | ";
proc(j]=index+l;
cout<<"\n--------------------------------------------------------\n";
sum—0:
if(gc[j]<l0)
cout<<0;
cout<<gc[j]<<” ";
sum+=gc[j]:
cout<<end1;
atat=(sum* I.0)/p;
t"<<tat[i]<<end1;
awt=awt+wt[i];
awt=(awt*1.0)/p;
return 0;
As an exampe, SJF scheUuWng, consder the folowing set of processes, w%h the
length of the CPU burst given in millisecond:
Burst Time
PI
P4 3
Using SJF scheduling, we would schedule these processes according to the following Gantt
P4 P1 P3 P2
9 16 24
The waiting time is 3 milliseconds for process P1,16 milliseconds for process P2.9
milliseconds for process P3, and 0 milliseconds for process P4. Thus, Ihe average wailing time is
(3+16+9+0)/4=7 milliseconds. By comparison, if we were using the FCFS scheduling scheme,
the average waiting time would be 10.25 milliseconds.
The SJF algorithm can be either Preemptive or non-Preerriptive. The choice arises when
a ncw process arrives ai ihe ready queue while a previous process is still executing. The next
CPU burst of the newly arrived process may be shorter than what is left of the currently
executing process.
1. According to the definition, shori processes are eheculed first and then followed by
longer process.
2. The throughput is increased because more proccsscs can bc cxccuicd in less nmount of time,
<• DISADVANTAGES: -
1. The time taken by a yrocc.ss mtist bc known by the CPU bcforChanJ, 'hich is not yos.sible.
2. Longer proccsrcs will havc morc waiting time, cx'cniuaIIy they'll xufrcr stcn'atinn.
• CONCLUSION-
After all we conclude that the we can understand the logic of Shortest-job-first Scheduling
and Round-Robin Scheduling.