Ini listing programnya :
# include
# include
main()
{
int k=0,ptime[25],n,s=0,i,sum=0, atime[25],at[25];
char name[25][25], m[25][25];
int t,p,time[10],j,l;
float avg;
printf("===============================================\n");
printf(" PROGRAM PENJADWALAN SHORTEST JOB FIRST (SJF) \n");
printf("===============================================\n\n");
printf ("Masukkan jumlah proses: ");
scanf ("%d",&n);
printf ("\n\n");
for(i=0;i
printf("Masukkan nama proses ");
printf("%d : ",i+1);
scanf("%s",name[i]);
}
printf("\n \n");
for(i=0;i
printf("Masukkan lama proses ");
printf("%s : ",name[i]);
scanf("%d",&ptime[i]);
}
printf("\n");
printf("---------------------------------");
printf("\n| Nama Proses \t| Lama Proses \t|\n");
printf("---------------------------------\n");
for(i=0;i
printf("|\t %s \t|\t %d \t|\n",name[i],ptime[i]);
printf("---------------------------------\n");
}
printf("\n \nPENJADWALAN SJF \n \n");
for(i=0;i
time[i]=ptime[i];
at[i]=atime[i];
}
for(i=0;i
for(j=i+1;j
if(time[i]>time[j])
{
p=time[i];
time[i]=time[j];
time[j]=p;
l=at[i];
at[i]=at[j];
at[j]=l;
strcpy(m[i],name[i]);
strcpy(name[i],name[j]);
strcpy(name[j],m[i]);
}
}
}
printf("Tabel setelah diurutkan berdasarkan SJF");
printf("\n");
printf("---------------------------------");
printf("\n| Nama Proses \t| Lama Proses \t|\n");
printf("---------------------------------\n");
for(i=0;i
printf("|\t %s \t|\t %d \t|\n",name[i],time[i]);
printf("---------------------------------\n");
}
for(i=0;i
printf("\nProses %s dari %d ke %d \n",name[i],k,(k+time[i]));
k+=time[i];
}
for(i=0;i<(n-1);i++)
{
s+=time[i];
sum+=s;
}
avg=(float)sum/n;
printf("\n\nRata-rata Waktu Tunggu : \t");
printf("%2f",avg);
sum=avg=s=0;
for(i=0;i
s+=time[i];
sum+=s;
}
avg=(float)sum/n;
printf("\n\nRata-rata Turn Arround Time : \t");
printf("%2f",avg);
sum=avg=s=0;
printf("\n\n");
printf("\n\n=========================================\n");
printf("Terimakasih telah menggunakan program ini\n");
printf("=========================================\n");
printf("\n");
}
//ini akhir dari program
Ok, sekian dulu postingan kali ini. Bagi saudara-saudara yang lebih expert tulung dibantu supaya program ini lebih sempurna dengan mampu menghitung arrival time dari proses.
1 komentar:
bagus banget...!! salam kenal ...!!! :-)
Posting Komentar