Upload
sriharsha-koritala
View
217
Download
0
Embed Size (px)
Citation preview
7/25/2019 OS_Lab_Manual_CSE-V
1/23
DRONACHARYAGROUPOFINSTITUTIONS,GREATERNOIDA
AffiliatedtoMahamayaTechnicalUniversity,Noida
Approvedby
AICTE
OperatingSystemLab(ECS 551)
7/25/2019 OS_Lab_Manual_CSE-V
2/23
Index
SERIALNUMBER NAMEOFTHEEXPERIMENT
1 PROGRAMTOIMPLEMENTTHECONCEPTSOFFCFS
2 PROGRAMTOINPLEMENTTHECONCEPTSOFSJF
3 PROGRAMTOIMPLEMENTTHECONCEPTSOFROUNDROBIN
4 PROGRAMTOIMPLEMENTTHECONCEPTSOFPRIORITYSCHEDULING
5 PROGRAMTOIMPLEMENTTHECONCEPTSOFFIRSTFIT
6 PROGRAMTOIMPLEMENTTHECONCEPTSOFBESTFIT
7 PROGRAMTOIMPLEMENTTHECONCEPTSOFNEXTFIT
7/25/2019 OS_Lab_Manual_CSE-V
3/23
1 /*PROGRAMTOIMPLEMENTTHECONCEPTSOFFCFS*/
#include
#include
voidmain()
{
intbt[3],wt[3],at[3],ft[3],tat[3];
inti,n,sum=0;
floatawt;
charp[3][9];
clrscr();
printf("\nEntertheprocessandbursttime:");
for(i=0;i
7/25/2019 OS_Lab_Manual_CSE-V
4/23
for(i=0;i
7/25/2019 OS_Lab_Manual_CSE-V
5/23
OUTPUT:
FIRSTCOME,FIRSTSERVE
Process Bursttime Arrivaltime Waitingtime Finishtime Turnaroundtime
process1 10 1 0 10 9
process2 20 2 10 30 28
process2 30 3 30 60 57
2 /*PROGRAMTOINPLEMENTTHECONCEPTSOFSJF*/
#include
#include
voidmain()
{
intbt[3],at[3];
intwt[3],ft[3],tat[3];
floatawt;
intn,i,sum=0,j,x,z;
charp[3][9],y[9];
clrscr();
printf("\nEntertheprocessandbursttime:");
for(i=0;i
7/25/2019 OS_Lab_Manual_CSE-V
6/23
printf("\nTheactualorder:\n");
printf("\nProcess\tBursttime");
for(i=0;i
7/25/2019 OS_Lab_Manual_CSE-V
7/23
ft[i]=ft[i1]+bt[i];
for(i=0;i
7/25/2019 OS_Lab_Manual_CSE-V
8/23
OUTPUT:
Theactualorder:
Process Bursttime
p1
10
p2 20
p3 30
Theordertheyareaexecuted:
Process Bursttime Arrivaltime Waitingtime Finishtime Turnaroundtime
p1
30
3
0
30
27
p2 20 2 30 50 48
p3 10 1 50 60 59
Averagewaitingtime:26.666666
7/25/2019 OS_Lab_Manual_CSE-V
9/23
3 /*PROGRAMTOIMPLEMENTTHECONCEPTSOFROUNDROBIN*/
#include
#include
voidmain()
{
intbt[3],at[3],tq;
intft[3],tat[3];
intec={0,0,0},i,bt1[3];
charp[3][9];
clrscr();
printf("\nEntertheprocessandbursttime:");
for(i=0;i
7/25/2019 OS_Lab_Manual_CSE-V
10/23
{
if(bt[i]
7/25/2019 OS_Lab_Manual_CSE-V
11/23
/*OUTPUTFORROUNDROBIN*/
INPUT:
Enterthe
process
and
burst
time:
p1 24
p2 3
p3 4
Enterthearrivaltime:
1
2
3
Enterthequantum:
5
OUTPUT:
ROUNDROBINSCHEDULING
Process Bursttime Arrivaltime Finishtime Turnaroundtime
1 p1 4 1 31 30
2 p2 3 2 8 6
3p3
4
3
12
9
7/25/2019 OS_Lab_Manual_CSE-V
12/23
4/*PROGRAMTOIMPLEMENTTHECONCEPTSOFPRIORITYSCHEDULING*/
#include
#include
voidmain()
{
intbt[3],at[3],pr[3];
intwt[3],ft[3],tat[3];
intn,i,sum=0,j,x,z,t;
floatawt;
charp[3][9],y[9];
clrscr();
printf("\nEntertheprocess,bursttimeandpriority:");
for(i=0;i
7/25/2019 OS_Lab_Manual_CSE-V
13/23
{
x=pr[j];
pr[j]=pr[i];
pr[i]=x;
strcpy(y,p[j]);
strcpy(p[j],p[i]);
strcpy(p[i],y);
z=bt[j];
bt[j]=bt[i];
bt[i]=z;
t=at[j];
at[j]=at[i];
at[i]=t;
}
}
wt[0]=0;
for(i=1;i
7/25/2019 OS_Lab_Manual_CSE-V
14/23
awt=sum/3.0;
printf("\nPRIORITYSCHEDULING:\n");
printf("\nTheordertheyareexecuted:\n");
printf("\nProcessPriority
Burst
time
Arrival
time
WaitingtimeFinishtimeTurnaroundtime");
for(i=0;i
7/25/2019 OS_Lab_Manual_CSE-V
15/23
OUTPUT:
Theactualorder:
ProcessBurst
time
Priority
p1 10 8
p2 20 3
p3 30 5
PRIORITYSCHEDULING
Theorder
they
are
executed:
Process Priority Bursttime Arrivaltime Waitingtime Finishtime Turnaroundtime
1 p1 3 20 2 0 20 18
2 p2 5 30 3 20 50 47
3 p3 8 10 1 50 60 59
Averagewaiting
time:23.333333
7/25/2019 OS_Lab_Manual_CSE-V
16/23
5 /*PROGRAMTOIMPLEMENTTHECONCEPTSOFFIRSTFIT*/
#include
#include
voidmain()
{
charp[4];
inti,partitionsize[4],x=0,c=0;
intprocess_size;
printf("\nEnterthe
partition
and
partitionsize:");
for(i=0;i
7/25/2019 OS_Lab_Manual_CSE-V
17/23
/*OUTPUTFORFIRSTFIT*/
INPUT:
Enterpartition
and
partitionsize:
p1 16
p2 22
p3 18
p4 10
Enterprocess_size:
20
OUTPUT:
Storedinpartition:2
Partitionsize:22
Externalfragmentation:2
7/25/2019 OS_Lab_Manual_CSE-V
18/23
6 /*PROGRAMTOIMPLEMENTTHECONCEPTSOFBESTFIT*/
#include
#include
voidmain()
{
intprs,n,ps[10],i,l,j=10,k,min,d[10];
clrscr();
printf("\nEnterthenumberofpartitions:");
scanf("%d",&n);
printf("\nEnterthesizeofeachpartition:");
for(i=0;i
7/25/2019 OS_Lab_Manual_CSE-V
19/23
break;
}
for(i=l;i=0)
{
printf("\nTheindextowhichprocessisallocated:%d",k);
printf("\nThesizeofthepartitiontowhichtheprocess
isallocated:%d",ps[k]);
printf("\nExternalfragmentation:%d",ps[k]prs);
j=1;
if(j==0)
printf("\nProcesssizeisgreaterthaneachofthepartition");
}
7/25/2019 OS_Lab_Manual_CSE-V
20/23
/*OUTPUTFORBESTFIT*/
INPUT:
Enterthenumberifpartitions:4
Enterthesizeofeachpartition:
16
18
12
11
Entertheprocesssize:10
OUTPUT:
Difference: 6 8 2 1
min:1
Theindextowhichprocessisallocated: 3
Thesizeofthepartitiontowhichtheprocessisallocated: 11
Externalfragmentation: 1
7/25/2019 OS_Lab_Manual_CSE-V
21/23
7 /*PROGRAMTOIMPLEMENTTHECONCEPTSOFNEXTFIT*/
#include
#include
voidmain()
{
intprs,n,ps[10],i,j=0,k;
clrscr();
printf("\nEnterthenumberofpartitions:");
scanf("%d",&n);
printf("\nEnterthesizeofeachparition:");
for(i=0;i
7/25/2019 OS_Lab_Manual_CSE-V
22/23
j=1;
break;
}
}
if(j==0)
printf("\nTheprocesssizeisgreaterthaneachofthepartition");
getch();
}
/*OUTPUTFOR
NEXT
FIT*/
1stCONCEPTIMPLEMENTATION:
INPUT:
Enterthe
number
of
partitions:
4
Enterthesizeofeachpartition:
14
16
20
18
Enterthe
size
of
the
process:
10
Enterthelastallocatedmatrix:2
7/25/2019 OS_Lab_Manual_CSE-V
23/23
OUTPUT:
Lastallocatedblock:20
Theindex
value
to
which
process
is
allocated:
3
Thesizeofthepartitiontowhichprocessisallocated:18
Externalfragmentation:8
2ndCONCEPTIMPLEMENTATION
INPUT:
Enterthenumberofpartitions:3
Enterthesizeofeachpartition:
20
22
18
Enterthe
size
of
process:
24
Entertheindexoflastallocatedmatrix:1
OUTPUT:
Lastallocatedblock:22
Theprocess
size
is
greater
than
each
of
the
partition.