java - Idle time for Earliest deadline algorithm -


i can't figure out how show correct diagram earliest deadline first algorithm idle times. far here code:

import java.util.*;   class deadlineprototype {     public static void main(string args[])     {         scanner sc = new scanner(system.in);          system.out.println("enter no. of processes : ");         int n=sc.nextint();         int job[]=new int[n+1];         int burst[]=new int[n+1];         int newburst[]=new int[n+1];         int arrival[]=new int[n+1];         int deadline[]=new int[n+1];         int wt[]=new int[n+1];         int turn[]=new int[n+1];         int tot_turn=0;         int tot_wait=0;         float avg_turn=0;         float avg_wait=0;         int j;          for(int m = 1; m <= n; m++)         {             arrival[m]=m;         }         for(int m = 1; m <= n; m++)         {             job[m]=m;         }          for(int m = 1; m <= n; m++)         {             system.out.println("enter arrival time, burst time , deadline of process "+(m)+"(0 none):");             arrival[m]=sc.nextint();             burst[m]=sc.nextint();             deadline[m]=sc.nextint();              if (deadline[m]==0)             {                 deadline[m]=1000;             }         }          int temp;         for(int = 0; < n; i++)         {             for(j = i; j < n; j++)             {                 if(arrival[j+1] == arrival[j])                 {                      if(deadline[j+1] < deadline[j])                     {                         temp=deadline[j+1];                         deadline[j+1]=deadline[j];                         deadline[j]=temp;                          temp=job[j+1];                         job[j+1]=job[j];                         job[j]=temp;                          temp=burst[j+1];                         burst[j+1]=burst[j];                         burst[j]=temp;                          temp=arrival[j+1];                         arrival[j+1]=arrival[j];                         arrival[j]=temp;                      }                 }               }         }         turn[1]=burst[1];              for(int = 2; <= n; i++)         {             turn[i]=burst[i]+turn[i-1];             wt[i]=turn[i]-burst[i];         }         for(int = 1; <= n; i++)         {             tot_turn+=(wt[i]+burst[i])-arrival[i];             avg_turn=(float)tot_turn/n;             tot_wait+=wt[i]-arrival[i];             avg_wait=(float)tot_wait/n;         }         system.out.println("----------earliest deadline scheduling diagram----------");         for(int m = 1; m <= n; m++)         {             if(deadline[m]==1000)             {                 deadline[m]=0;             }             if(wt[m]==0)             {                 system.out.println("0"+wt[m]+" _____");              }             else             {                 system.out.println(wt[m]+" _____");              }             system.out.println("  |     |");              system.out.println("  |job "+job[m]+"|");              system.out.println("  |_____|");             try             {                 //newburst[m]=(burst[m]*1000);                 thread.sleep(1000);               } catch (interruptedexception ie)             {                 system.out.println(ie.getmessage());             }         }         system.out.println((wt[wt.length-1]+burst[burst.length-1]));     } } 

if input 2 processes without idle show correct output:

    enter no. of processes :      2     enter arrival time, burst time , deadline of process 1(0 none):     0 17 0     enter arrival time, burst time , deadline of process 2(0 none):     0 13 10     ----------earliest deadline scheduling diagram----------     00 _____       |     |       |job 2|       |_____|     13 _____       |     |       |job 1|       |_____|     30 

but if has idle time output:

    enter no. of processes(5-10):      2     enter arrival time, burst time , deadline of process 1(0 none):     0 5 0     enter arrival time, burst time , deadline of process 2(0 none):     10 10 10     ----------earliest deadline scheduling diagram----------     00 _____       |     |       |job 1|       |_____|     5 _____       |     |       |job 2|       |_____|     15 

i'm still stuck doing have no idea how can show idle time, please me this.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -