java - Using round robin algorithm to calculate time needed -


maybe out there feeling friendly , find brain teaser interesting.. feel maybe started confusing myself.

the object of calculate, using round robin algorithm, time take of processes complete. have prompt user time quantum, , how many processes calculate. there, throw statement based on many processes there assign process arival time , burst time.

for arent familiar, time quantum how many cycles process before switches next, burst how many cycles takes complete process, , of course arival time how many cycles have completed before arives. simple algorithm, it's show how cpu's schedule. if @ fantastic! i'm lost. wanted in c#, programming skills less sufficent in c# that.

the 2 problems having in if statements, started lose myself, , whatever reason, gives me error when compiling dif < parrive.get[ii] or dif < parrive.get(ii) or assigning parrive.get[ii] variable @ beginning of if statements , using variable(as shown)...

import java.io.*; import java.util.*;  public class thread{             public thread() {         inputexecute();     }      public void inputexecute(){          scanner x = new scanner(system.in);         int xx = 0;          string choice = null;         arraylist parrive = new arraylist();         arraylist pburst = new arraylist();          while (true){             system.out.println("enter time quantum: ");             int quant = x.nextint();             system.out.println("enter number of processes: ");             int pnum = x.nextint();              for( int i=0; i<pnum; i++)             {                 system.out.println("enter arival p"+i+": ");                 int arrive = x.nextint();                 parrive.add(arrive);                  system.out.println("enter burst time: ");                 int burst = x.nextint();                 pburst.add(burst);                   }              int dif;             for(int ii=0; ii < pnum; ii++)             {                 int asw == parrive.get[ii];                  if (asw < quant)                 {                     dif = quant - asw;                 }                                     if (quant < asw)                 {                     asw = asw - quant;                 }                 if (dif > 0)                 {                  }             }         } /* end while*/     } /* end exec input*/ } /* class thread */ 

the way write it

list<integer> parrive = new arraylist<integer>();  for(int asw: parrive) {     int dif = math.abs(asw - quant);     if (dif == 0) continue;     // if dif > 0  } 

i assuming

asw = asw - quant; 

should be

dif = asw - quant; 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -