Berikut ini adalah source code program penghitungan waiting time dan turn around time sistem penjadwalan proses menggunakan Shortest Job First dengan C++. Program ini di buat pake aplikasi Array. Tapi sayangnya gag bisa untuk menghitung arrival time. so, cekidot
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"); }Semoga Bermanfaat ...
0 komentar:
Posting Komentar