0% found this document useful (0 votes)
7 views11 pages

Osy Microproject

OPERATING SYSTEM (22516)

Uploaded by

himanshugk2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views11 pages

Osy Microproject

OPERATING SYSTEM (22516)

Uploaded by

himanshugk2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

A

Micro Project Report


On
"A Report on Scheduling Algorithm
SJF”
SUBMITTED FOR COURSE
Operating System (22516)

Department of Information Technology


Of scbezae ZESI
SUBMITTED BV

Sr. No. Nsmz Roll Number


1 Makarand Satish Khicte 45
2 Vljayraj Anurath Garad 42
Rushinath Krushnadeo Ambure 64

UNDER THE GUIDANCE OF


MR. L.B.DETHE

ns»nnrsmsv or eiroeuArio ncusozocvn«ceszcnisc,


SVERI's COLLEGE OF ENGINEERING (POLYTECHNIC), PANDHARPUR- 413304
2019-20
AFFILIATED TO

Scanned with CamScanner


Certificate

Thc project rcpori entitled “A Report on Scheduling Algorithm SJF”


Submitted by

l. MMamnd Satish Khistc.


2. Vijaymj Anumth Gamd.
3. Rushinath Krushnadeo Ambure.

We are approved for the Diploma of Engineering in Information Technology Engineering


from SVERI's Collese of En ineering (Polytechnic), Pandharpur.

Name of guide Name of H.O.D.


(Mr. L.B.Dethe) (Mr. A.S.Bhise)
Department of lT Engineering Department of IT Engineering
SVERl's COE (Poly), Pandharpur. SVERl's COE (Poly),Pandharpur.

Principal
(Dr. N. D. Misal)

Date:-
Place: Pandharpur

Scanned with CamScanner


“A Report on Scheduling Algorithm SJF” has been developed successfully with a great
contribution of four students in n period of one year. We like to appreciate their guidance,
encouragement and willingness since withoui their support the project would not have been a
success. We would like io give our heartfelt gratitude to Principal Dr.N.D.Misal, HOD
Mr.A.S.Bhise, Department of Information Technology, Mr.L.B.Dethe, who is the supervisor of
our project for helping and encouraging us in many ways to make our project a success. We
would never been able to finish our work without great support and enthusiasm from friends and
support from our family. We would like to thank the department of Information Technology, for
giving us permission to initiate this project and successfully finish it.

Scanned with CamScanner


4• SCHEDULING ALGORITHM: -

1. First -come, First-served scheduling

2. Shortest-job-first Scheduling

3. Priority Scheduling

4. Round-Robin Scheduling

Scanned with CamScanner


1. SHORTEST-JOB-FIRST SCHEDULING: -

• INTRODUCTION: -

A different approach to CPU scheduling is the shortest-job-first (SJF) scheduling


algorithm. This algorithm associatc with cach process the length of thc process's next CPU burst.
When the CPU is available, it is assigned to the process that has the smallest next CPU burst.
If the nexi CPU bursts of two processes are the same, FCFS scheduling is used to brake ihe tie.
Note that a more appropriate ierm for this scheduling method would be the shortest-next-CPU-
burst algorithm because scheduling depends on the length of the next CPU burst of a process
rather than its total length.

Scanned with CamScanner


4• C++ CODE:-

#include<bits/stdc++.h>
using namespace std;

int main()

/*Visit - www.programmingwithbasics.com*/

int p, i, j, sum=0, min, index;


float awt=0, atat=0;

cout<<"\nEnter The Total Number of Process: ";

int proc[p];

int *cbt = new int[p];


int *wt = new int[p];
int *gc = new int[p);
int *tat = new int[p];
int *tmp = new int[p];

cout<<”\nEnter CBT of Process:\n”;

for(i=0; i<p; i++)


( cin>>cbt[i];
tmp[i]=cbt[i];

sort(cbt, cbt+p);

cout<<"\n=— —=—— ——=——==—— —— —————=——===———


==——\n";
cout<<"ttttGantt. Chart";

Scanned with CamScanner


==— \n";

for(j=0; j<=p; j++)


min=100;
for(i=0; up; i++)

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:

for(j=0: j<=p; j++)

if(gc[j]<l0)
cout<<0;
cout<<gc[j]<<” ";
sum+=gc[j]:

cout<<end1;

atat=(sum* I.0)/p;

Scanned with CamScanner


cout<<”tnProcess\t{tCB tWaiting Time\tTurn Around Time";
cout<<”\n--------------------------------------------------------\n“;

for(i=0; i<p; i++) cout<<"P["<<proc[i]<<"]\t\t”<<cbt[i]<<"\t"<<wt[i]<<"\t\

t"<<tat[i]<<end1;
awt=awt+wt[i];

awt=(awt*1.0)/p;

cout<<"\n\nTota1 Waiting Time: "<<awt; cout<<"\n\


nTotal Turn Around Time: "<<atat<<endl;

return 0;

Scanned with CamScanner


•t• EXAMPLE:

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.

Scanned with CamScanner


c• ADVANTAGES : -

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.

Scanned with CamScanner


4• RESULT-
Thus we can understand the working of Shortest-job-first Scheduling and Round-Robin
Scheduling with example.

• CONCLUSION-
After all we conclude that the we can understand the logic of Shortest-job-first Scheduling
and Round-Robin Scheduling.

Scanned with CamScanner

You might also like