Resources » Articles/Knowledge Sharing » General

Sjf scheduling program in c


Last Updated:   Category: General    
Author: Member Level: Silver    Points: 2






#include
int main()
{
int n,b[12],b1[12],j[12],w[12],e[12];
int i,k,t,t1;
float aw=0,ae=0;
printf("\n Enter the number of Jobs:");
scanf("%d",&n);
for(i=0;i {
printf("Enter the bursttime of Job %d:",i+1);
scanf("%d",&b[i]);
b1[i]=b[i];
j[i]=i;
}
for(i=0;i for(k=0;k if(b1[i] {
t=b1[i];
b1[i]=b1[k];
b1[k]=t;
}
printf("\n Job \t bursttime \t Waitingtime \t Turnaroundtime");
for(i=0;i {
if(i==0)
{
w[0]=0;
e[0]=b1[0];
}
else
{ w[i]=e[i-1];
e[i]=e[i-1]+b1[i];
}
printf("\n %d \t\t %d \t\t %d \t\t %d",i+1,b1[i],w[i],e[i]);
aw+=w[i];
ae+=e[i];
}
aw/=n;
ae/=n;
printf("\n Average Waiting time is : %f",aw);
printf("\n Average Turnaround time is :%f",ae);
return(0);
}


Did you like this resource? Share it with your friends and show your love!




Responses to "Sjf scheduling program in c"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Submit Article     Return to Article Index

    Awards & Gifts
    Active Members
    TodayLast 7 Daysmore...

    ISC Technologies, Kochi - India. Copyright © All Rights Reserved.