0% found this document useful (0 votes)
15 views3 pages

About Linked List and Implementation Using An Example Program

Linked list and many things like stack and queue

Uploaded by

nandhinidevi0815
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)
15 views3 pages

About Linked List and Implementation Using An Example Program

Linked list and many things like stack and queue

Uploaded by

nandhinidevi0815
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/ 3

4A) APPLICATION OF QUEUE – FCFS SCHEDULING

#include<stdio.h>
int main()
{
int nop,wt=0,tat=0,i;
int bt[10];
float totwt=0.0,tottat=0.0;
float avgwt=0.0,avgtat=0.0;
printf("\n\tEnter the number of process:");
scanf("%d",&nop);
for(i=1;i<=nop;i++)
{
printf("\n\tEnter the burst time for the process%d in msecs:",i);
scanf("%d",&bt[i]);
}
for(i=0;i<nop;i++)
{
bt[0]=0;
wt = wt + bt[i];
totwt=totwt + wt;
}
printf("\n\t\tTotal waiting time: %0.2f ms",totwt);
avgwt=(float)totwt/(float)nop;
printf("\n\t\tAverage waiting time:%0.2f ms",avgwt);for(i=0;i<=nop;i++)
{
tat=tat + bt[i];
tottat=tottat + tat;
}
printf("\n\t\tTotal Turn around time: %0.2f ms",tottat);
avgtat=(float)tottat/(float)nop;
printf("\n\t\tAverage Turn around time: %0.2f ms",avgtat);
return 0;
}

4 B) APPLICATION OF QUEUE -CPU SCHEDULING ALGORITHM – ROUND


ROBIN
#include<stdio.h>
int main()
{
int bursttime[10][10],bt[10][10];
int i,j,nop,k=0,tq,sum=0;
float avg;
printf("\nEnter the Number of processes:");
scanf("%d",&nop);
printf("\n\tEnter the time quantum;");
scanf("%d",&tq);
for(i=0;i<10;i++)
for(j=0;j<10;j++)
{
bursttime[i][j]=0;
bt[i][j]=0;
}
for(i=0;i<nop;i++)
{ j=0;
printf("\n\tEnter the process time for process %d;",i+1);
scanf("%d",&bursttime[i][j]);}
for(j=0;j<10;j++)
for(i=0;i<nop;i++)
{ bt[2*j][i]=k;
if((bursttime[i][j]<=tq)&&(bursttime[i][j]!=0))
{
k=k+bursttime[i][j];
bt[2*j+1][i]=k;
} else if(bursttime[i][j]!=0)
{
bursttime[i][j+1]=bursttime[i][j]-tq;
k=k+tq;
bt[2*j+1][i]=k;
} else
{
bt[2*j][i]=0;
bt[2*j+1][i]=0;
} }
for(i=0;i<nop;i++)
sum=sum+bt[0][i];
for(i=0;i<nop;i++)
for(j=1;j<10;j++)
{
if((bt[j][i]!=0)&&(bt[j+1][i]!=0)&&((j+1)%2==0))
{
sum=sum+((bt[j+1][i]-bt[j][i]));
} }
avg=(float)sum/nop;
printf("\n\n\t\tAverage waiting time:%0.2f millisecs",avg);
sum=avg=0;
for(j=0;j<nop;j++)
{
i=1;
while(bt[i][j]!=0)
i++;
sum=sum+bt[i-1][j];
}
avg=(float)sum/nop;
printf("\n\n\t\tAverage Turnaround time: %0.2f ms\n",avg);
return 0;
}

You might also like